English 中文(简体)
j(a)项所述内容没有删除
原标题:jQuery on() fails to remove an element

I m doing a dynamic table to collect passengers personal data. This table have above a control to add more rows at the end, every row is a copy of the first one, and that one have as last element a link that I use as a control for deleting that row.

问题在于,只有第一行——不是动态创造的——才是实际工作的唯一一条,能够消除自己。

因此,由于缺乏最初的行文(但又是一个问题xD),该页甚至停止建立新的行文。

这是我用来删除行文的法典:

$( .remove ).on("click",function(event){
    event.preventDefault;
    $(this).parent().parent().remove();

    //alert(str);
    newRowNum -= 1;
});

and here is the live site if you want need to chek it out: http://www.micontrol.cl/~mvargas/wordpress/wp-transatacama/reservas-rapidas/tabladinamica.php

最佳回答

<>code>on( activities are only subject to elements that original in the DOM with its Objecttax. 号文件。 如果你想要把活动交给其他部分,那么你就需要有第二位选择。

问题回答
    <table id="test">
        <tr>
            <td>A</td>
            <td><a>Click</a></td>
        </tr>
         <tr>
            <td>B</td>
            <td><a>Click</a></td>
        </tr>
    </table>

    <p>
        <a id="insert">Copy</a>
    </p>

    <script type="text/javascript">
      $(document).ready(function(){

        $("#test").find("a").click(function(){

          $(this).parents("tr").remove();

        }); 

        $("#insert").click(function(){

          $("#test tr").first().clone(true).appendTo("#test");

        });

      });

   </script>

这里对你们来说是一个dle子:

http://jsfiddle.net/AdS8D/3/>rel=“nofollow> http://jsfiddle.net/AdS8D/3/

http://www.un.org。 添加衣帽功能。

回到使用克隆技术,但使用......clone(true)复制机。

你可以尝试这一法典:

$("#tabdata").on("click", ".remove", function(event){
    event.preventDefault;
    $(this).parent().parent().remove();
    newRowNum -= 1;
}); 




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签