Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 在原型函数中创建img和li,并附加到我的ul中 Setup.prototype.\u toImg=函数(fieldStore、url\u src、outputFormat、width、height、idImg、classImg){ this.field=fieldStore; this.src=url\u src; 这个。宽度=宽度; 高度=高度; this.class=classImg; this.id=idImg; var s=$(此.field); 变量li=$(“”{ 课程:“产品内容” }); 变量img=$(“_Jquery - Fatal编程技术网

Jquery 在原型函数中创建img和li,并附加到我的ul中 Setup.prototype.\u toImg=函数(fieldStore、url\u src、outputFormat、width、height、idImg、classImg){ this.field=fieldStore; this.src=url\u src; 这个。宽度=宽度; 高度=高度; this.class=classImg; this.id=idImg; var s=$(此.field); 变量li=$(“”{ 课程:“产品内容” }); 变量img=$(“

Jquery 在原型函数中创建img和li,并附加到我的ul中 Setup.prototype.\u toImg=函数(fieldStore、url\u src、outputFormat、width、height、idImg、classImg){ this.field=fieldStore; this.src=url\u src; 这个。宽度=宽度; 高度=高度; this.class=classImg; this.id=idImg; var s=$(此.field); 变量li=$(“”{ 课程:“产品内容” }); 变量img=$(“,jquery,Jquery,我正在使用此函数创建li的图像,li附加到我的ul,但不知何故它不会创建图像或li,我检查ul id是否正确,收入数据是否正确,因此我的问题是如何在原型函数中创建img和li Setup.prototype._toImg = function(fieldStore, url_src, outputFormat, width, height, idImg, classImg){ this.field = fieldStore; this.src = url_src; this.widt

我正在使用此函数创建li的图像,li附加到我的ul,但不知何故它不会创建图像或li,我检查ul id是否正确,收入数据是否正确,因此我的问题是如何在原型函数中创建img和li

Setup.prototype._toImg = function(fieldStore, url_src, outputFormat, width, height, idImg, classImg){
  this.field = fieldStore;
  this.src = url_src;
  this.width = width;
  this.height = height;
  this.class = classImg;
  this.id = idImg;

    var s = $(this.field);

  var li =$("<li>", {
    class: "productContent__ul__li"
  });

    var img = $("<img/>", {
      src: this.src,
      id: this.id,
      class: this.class,
      width: this.width,
      height: this.height
    }).appendTo(li);

    li.appendTo(s);
}

that._toImg("#productContent__ul", comfirmUrl, "png", 45, 45, null, "comfirm__image");


    你可以在你的方法中做一些简单的调试来缩小问题的范围。这里的问题似乎可以解决~。你可能把
    comfirmUrl
    变量的名称拼写错了吗?应该改为
    confirmUrl
    吗?我不知道为什么我要检查comfirmUrl,仍然不能。
    <div id="formDisplay-productContent">
        <ul id="productContent__ul"></ul>
    </div>