动态创建li标签与静态之间的区别 [英] difference between dynamically created li tag vs static

查看:101
本文介绍了动态创建li标签与静态之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题,jQuery如何在ul中创建li标签说例子;

I got question, how li tag created in ul by jQuery say example;

   $("#selectedPropertyImg_Wrapper").find("#myGallery").append("<li><img src=" + PropertyDetail.d_img_urlname[index].text() + "/></li>");

不同然后在ul中硬编码的li标签...之所以要问,因为我正在尝试在GalleryView jQuery插件中上传图片,在图库视图中从网址动态加载图片内容插件适用于静态但似乎没有动态创建代码,即使我已经测试它生成正好的li格式标签,我在最后ajax函数调用galleryView插件...

different then the li tag hard coded in ul... the reason why asking because i am trying to upload images in GalleryView jQuery plugin, Loading images content dynamically from url in Gallery View plugin which works fine with static but doesn't seems dynamically created code, even i have tested it generate exactly li format tag and i am calling galleryView plugin at the end ajax function...

非常感谢提前...

推荐答案

我有解决方案。我的动态元素(li标签)在dom准备好时不可用。所以我制作了separte jQuery插件,调用xml并读取和验证图像。一旦验证完成,我将我的li附加到URL。然后我有另一个jquery插件来读取其余的xml数据。我在document.ready函数下的html页面我调用图像插件,然后是第二个插件和调用GalleryView ...一切正常...

I have the solution. my dynamic elements (li tags) weren't available at the time the dom was ready. so i made separte jQuery plugin, call the xml and read and validate images. once validation complete i append my li along with URL. then I have another jquery plugin to read rest of xml data. I html page under document.ready function i call images plugin, followed by 2nd plugin and the call GalleryView... all works ...

所以我希望这个答案我的问题和解决方案......

so i hope this answer to my question along with solution...

$.fn.initializeImg = function (CP_ID) {

$.ajax({
    type: "GET",
    url: "XML4.xml",
    dataType: "xml",
    async:false,
    success: function (xml) {

           $("#selectedPropertyImg_Wrapper").find("#myGallery").append("<li><img src= " + gb_var.j_propertyImgURLs[index].text() + " /></li>");

html页面中的

in html page

  $(document).ready(function () {

    //initialize gallery images from url//

        $(this).initializeImg(requested_Property);


        //-------pass property ID to plugin ----//

        $(this).getPropertyDetail(requested_Property);


        //-----image gallery view---//
        $(function () {
            $('#myGallery').galleryView({
                panel_width: 750,
                panel_height: 500,
                frame_width: 100,
                frame_height: 67
            });
        });
   }

这篇关于动态创建li标签与静态之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆