Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.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 在克隆子项后删除html标记id_Jquery - Fatal编程技术网

Jquery 在克隆子项后删除html标记id

Jquery 在克隆子项后删除html标记id,jquery,Jquery,我试图在克隆id后将其删除,但该id不起作用我有以下问题: 负责人: $(window).load(function() { $('#datepicker-example7-start').Zebra_DatePicker({ direction: false, pair: $('#datepicker-example7-end') }); $('#datepicker-exampl

我试图在克隆id后将其删除,但该id不起作用我有以下问题:

负责人:

    $(window).load(function() {
          $('#datepicker-example7-start').Zebra_DatePicker({
             direction: false,
             pair: $('#datepicker-example7-end')
        });

        $('#datepicker-example7-end').Zebra_DatePicker({
            direction: true
          });
      });
正文:

我需要的是在调用datepicker on head标记后删除id,这样当我单击add row submit按钮并调用clone方法时,它将不会克隆id为的输入标记,也不会再次加载日历图标。。。日历图标似乎与每个克隆重叠,这使得它不可单击,日历仅在单击textbox时加载(第一行,textbox和日历图标都可单击)


谢谢你的帮助

我不太理解这个问题,但是如果你只是想删除id,试试这个

 $('input.dp-start:last').attr("id","");


JavaScript区分大小写。它是
removeAttr
,而不是
removeAttr
。检查控制台也总是有帮助的。您可能会被抛出一个错误,例如“RemoveAttr”方法不存在或类似的错误。已更改为小写,但仍然无法运行Anks@j08691以进行更正。mei也尝试了此操作,但无效newRow=templateRow.cloneNode(true)。RemoveAttr('id');场景是这样的,我有一个克隆行,其中两个输入字段通过id调用函数onload。。。我需要的是不要在克隆行上加载id,这样它就不会再次调用函数了。谢谢@swsaok,如果你能给我一个JSFIDLE代码,我可以帮你解决这个问题,因为可能是代码中的其他东西使它无法工作,因为语法是正确的。另一个假设是,id可能会调用克隆后再次显示css这就是为什么它会显示不应该显示的图标如果你需要更详细的帮助,我可以给你我的电子邮件这里是@swsa[它可能无法运行,因为插件外部资源无法全部上载
   var elements, templateRow, rowCount, row, className, newRow, element;
var i, s, t;

/* Get and count all "tr" elements with class="row".    The last one will
 * be serve as a template. */

if (!document.getElementsByTagName)
    return false; /* DOM not supported */
elements = document.getElementsByTagName("tr");
templateRow = null;
rowCount = 0;
for (i = 0; i < elements.length; i++) {
    row = elements.item(i);

    /* Get the "class" attribute of the row. */
    className = null;
    if (row.getAttribute)
        className = row.getAttribute('class');
    if (className === null && row.attributes) {    // MSIE 5
        /* getAttribute('class') always returns null on MSIE 5, and
         * row.attributes doesn't work on Firefox 1.0.    Go figure. */
        className = row.attributes['class'];
        if (className && typeof(className) === 'object' && className.value) {
            // MSIE 6
            className = className.value;
        }
    } 

    /* This is not one of the rows we're looking for.    Move along. */
    if (className !== "row_to_clone_fw_emp")
        continue;

    /* This *is* a row we're looking for. */
    templateRow = row;
    rowCount++;
}
if (templateRow === null)
    return false; /* Couldn't find a template row. */

/* Make a copy of the template row */
newRow = templateRow.cloneNode(true);

/* Change the form variables e.g. price[x] -> price[rowCount] */
elements = newRow.getElementsByTagName("input");
for (i = 0; i < elements.length; i++) {
    element = elements.item(i);
    s = null;
    s = element.getAttribute("name");
    if (s === null)
        continue;
    t = s.split("[");
    if (t.length < 2)
        continue;
    s = t[0] + "[" + rowCount.toString() + "]";
    element.setAttribute("name", s);
    element.value = "";
   /* element.find('#datepicker-example7-start').removeAttr('id'); 
    element.find('#datepicker-example7-end').removeAttr('id'); */
}



templateRow.parentNode.appendChild(newRow);

$('.dp-start:last').Zebra_DatePicker({
     direction: false,
     pair: $('.dp-end:last')
});

$('.dp-end:last').Zebra_DatePicker({
     direction: true
});

return true;
    $('input#datepicker-example7-start').RemoveAttr('id');
    $('input#datepicker-example7-end').RemoveAttr('id');
    $('input.dp-start:last').RemoveAttr('id');
    $('input.dp-end:last').RemoveAttr('id');
 $('input.dp-start:last').attr("id","");
 $('input.dp-start:last').removeAttr('id');