English 中文(简体)
页: 1 检查所有检查箱
原标题:jQuery check all checkboxes

I thought this would be simple I have a table with the first column a checkbox I am using this code to make the checkbox check all the other checkboxs

$( .checkall ).click(function () {
    $(this).parents( tbody:eq(0) ).find( :checkbox ).attr( checked , this.checked);
});

The HTML/Jquery code to create the table

 $("#menuarea").html( <a href="#!/home" id="gotohome"><div id="backmain" class="backbg">Back</div></a><div id="nav" class="backbgright">New Business Lead</div> +
                         <div id="dowithleads"></div> +
                         <table cellpadding="0" cellspacing="0" border="0" class="sortable paginated" id="manageleads"> +
    <thead> +
        <tr> +
            <th class="small"><input type="checkbox" class="checkbox checkall" value="Yes"></th> +
            <th class="sort-alpha">Created Time</th> +
            <th class="sort-alpha">Company</th> +
            <th class="sort-alpha">Lead Name</th> +
            <th class="sort-alpha">Phone No.</th> +
            <th class="sort-alpha bigger">Email</th> +
            <th class="sort-alpha">Lead Owner</th> +
            <th class="sort-alpha last">Lead Status</th> +
        </tr> +
    </thead> +
    <tbody> +
        <tr> +
            <td class="small"><input type="checkbox" class="formbox"></td> +
            <td>Mozilla 1.6</td> +
            <td>Win 95+ / OSX.1+</td> +
            <td class="center">1.6</td> +
            <td class="center">A</td> +
            <td class="center bigger">A</td> +
            <td class="center">A</td> +
            <td class="center last">A</td> +
        </tr> +
        <tr> +
            <td class="small"><input type="checkbox" class="formbox"></td> +
            <td>Mozilla 1.2</td> +
            <td>Win 94+ / OSX.1+</td> +
            <td class="center">1.5</td> +
            <td class="center">D</td> +
            <td class="center bigger">A</td> +
            <td class="center">N</td> +
            <td class="center last">A</td> +
        </tr> +
 </table> );
最佳回答
问题回答

正式工作守则,在另外两人任职时已经写成,因此没有点想:

$(document).ready(function()
{

$( .checkall ).live( click , function () {
    checked = ($(this).attr( checked ) ==  checked ) ?  true  : false;
    $( :checkbox ).each(function(){ $(this).attr( checked , checked); });
});


$("#menuarea").html( <a href="#!/home" id="gotohome"><div id="backmain" class="backbg">Back</div></a><div id="nav" class="backbgright">New Business Lead</div> +
                         <div id="dowithleads"></div> +
                         <table cellpadding="0" cellspacing="0" border="0" class="sortable paginated" id="manageleads"> +
    <thead> +
        <tr> +
            <th class="small"><input type="checkbox" class="checkbox checkall" value="Yes"></th> +
            <th class="sort-alpha">Created Time</th> +
            <th class="sort-alpha">Company</th> +
            <th class="sort-alpha">Lead Name</th> +
            <th class="sort-alpha">Phone No.</th> +
            <th class="sort-alpha bigger">Email</th> +
            <th class="sort-alpha">Lead Owner</th> +
            <th class="sort-alpha last">Lead Status</th> +
        </tr> +
    </thead> +
    <tbody> +
        <tr> +
            <td class="small"><input type="checkbox" class="formbox"></td> +
            <td>Mozilla 1.6</td> +
            <td>Win 95+ / OSX.1+</td> +
            <td class="center">1.6</td> +
            <td class="center">A</td> +
            <td class="center bigger">A</td> +
            <td class="center">A</td> +
            <td class="center last">A</td> +
        </tr> +
        <tr> +
            <td class="small"><input type="checkbox" class="formbox"></td> +
            <td>Mozilla 1.2</td> +
            <td>Win 94+ / OSX.1+</td> +
            <td class="center">1.5</td> +
            <td class="center">D</td> +
            <td class="center bigger">A</td> +
            <td class="center">N</td> +
            <td class="center last">A</td> +
        </tr> +
 </table> );

});




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

热门标签