Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.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
Javascript 如何将类动态添加到列表标记<;李>;,在Imagepicker.js中。?_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 如何将类动态添加到列表标记<;李>;,在Imagepicker.js中。?

Javascript 如何将类动态添加到列表标记<;李>;,在Imagepicker.js中。?,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我已经将类和id动态地添加到div和image中,这样就可以正常工作了。 原始代码是:从image-picker.js中的第274行开始 但是它没有被添加,甚至我也看不到他们添加的这个默认类在html中没有添加。 所以,你能建议我如何在这里添加一些类,这样它也必须像这样以html的形式添加吗 container.append(jQuery("<li class='group_title some_class'>" + (option_group.attr("label")) +

我已经将类和id动态地添加到div和image中,这样就可以正常工作了。
原始代码是:从image-picker.js中的第274行开始

但是它没有被添加,甚至我也看不到他们添加的这个默认类在html中没有添加。 所以,你能建议我如何在这里添加一些类,这样它也必须像这样以html的形式添加吗

container.append(jQuery("<li class='group_title some_class'>" +   
(option_group.attr("label")) + "</li>"));
container.append(jQuery(“
  • ”)+ (选项_group.attr(“标签”)+“
  • ”);
    在创建元素本身时尝试添加,如下所示:

    ImagePickerOption.prototype.create_node = function() {
          var image, thumbnail;
          this.node = jQuery("<li/>", {
               class: 'yourclassnamehere',//here add your class
               id:'someid' //note: this should be unique
          }); 
          image = jQuery("<img class='image_picker_image'/>");
          image.attr("src", this.option.data("img-src"));
          thumbnail = jQuery("<div class='thumbnail'>");
          thumbnail.click({
            option: this
          }, function(event) {
            return event.data.option.clicked();
          }
    );
    
    ImagePickerOption.prototype.create_node=function(){
    var图像,缩略图;
    this.node=jQuery(“
  • ”{ class:'yourclassnamehere',//在此处添加您的类 id:'someid'//注意:这应该是唯一的 }); image=jQuery(“”); 缩略图。单击({ 选项:这个 },功能(事件){ return event.data.option.clicked(); } );
  • 任何时候。@navenkumark如果它对你有帮助,请接受它作为答案,让其他人不要再浪费时间回答这个问题!你能告诉我如何在其中获得所有选定的图片吗?@gurupasad-rao@NaveenKumarK你可能需要把它作为一个单独的问题发布,给出一些简单的细节,然后你会得到很多解决方案他的符合SO规则…:)好的,谢谢你的建议…我是新使用SO的…所以需要更多了解SO规则:)@GuruprasadRao
    container.append(jQuery("<li class='group_title'>" + 
    (option_group.attr("label")) + "</li>"));
    
    container.append(jQuery("<li class='group_title some_class'>" +   
    (option_group.attr("label")) + "</li>"));
    
    ImagePickerOption.prototype.create_node = function() {
          var image, thumbnail;
          this.node = jQuery("<li/>", {
               class: 'yourclassnamehere',//here add your class
               id:'someid' //note: this should be unique
          }); 
          image = jQuery("<img class='image_picker_image'/>");
          image.attr("src", this.option.data("img-src"));
          thumbnail = jQuery("<div class='thumbnail'>");
          thumbnail.click({
            option: this
          }, function(event) {
            return event.data.option.clicked();
          }
    );