English 中文(简体)
如果检查一个检查箱,然后删除一个内容
原标题:Check if a checkbox is checked and then delete an element
  • 时间:2012-01-11 11:39:44
  •  标签:
  • jquery
  • forms

我拿着一系列不同孩子的形式。 每个人都在那里有一个检查箱。 我试图做的是,如果检查其中的检查箱,就删除其中的一种表格。

<form id="placement-form">
</form>
<form id="placement-form1">
</form>
<form id="placement-form2">
</form>

我写了在“Qu”中的短功能,在理论上,如果检查箱是“检查”的,就应当删除表格,但我可以让它工作。 j 详细情况如下:

$(function() {
    $( .deleteSelected ).click(function() { //fire when the button is clicked
        $( #placement-form:checkbox:checked ).each(function() {
            $( #placement-form ).remove();                
        });
    });
});

It s probably a little muddled but I m still getting to grips with jQuery with a combination of the documentation and a bit of Googling..!

EDIT:尽管我刚才已经实现了这一文字,但现在只有一种形式(安插版)的Im。

最佳回答

审判

$(function() {
    $( .deleteSelected ).click(function() { //fire when the button is clicked
        $( form input:checkbox ).each(function() {
          var checkbox = $(this);  
          if(checkbox.is( :checked )) checkbox.parents( form ).remove();        
        });
    });
});

http://www.un.org。 方便

$( .deleteSelected ).click(function(){
    $( form input:checked ).parents( form ).remove();
});

http://jsfiddle.net

问题回答

$( #placement-form ) will find only an element with that ID, not others. You should write something like:

$( .deleteSelected ).click(function() {
    $(this).parents( form ).remove();
});




相关问题
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: &...

热门标签