English 中文(简体)
在下行使用 j鱼的表格中选择控制
原标题:Select controls in table in next row using jQuery

我的表格是:第一行,一栏是一栏,在第二行——<代码><asp:Check BoxList />上加到另一个表格。

我如何利用 j子在桌子上获取投入? 我想选择所有使用一个链接的人,并放弃使用另一个链接的人。

<table>
    <tr>
        <td>
            <table>
                <tbody>
                    <tr>
                        <td>
                            <!-- Anchor to click -->
                            <a onclick="do stuff" href="javascript://">Select all</a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
    </tr>
    <tr>
        <td>
            <!-- CheckboxList -->
            <table id="ctl00_commonForm_ctl00_ctl00_listCheck" class="list" border="0">
                <tbody>
                    <tr>
                        <td>
                            <!-- input to select -->
                            <input id="ctl00_commonForm_ctl00_ctl00_listCheck_0" name="ctl00$commonForm$ctl00$ctl00$listCheck$0" checked="checked" type="checkbox"><label for="ctl00_commonForm_ctl00_ctl00_listCheck_0">Date</label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <input id="ctl00_commonForm_ctl00_ctl00_listCheck_1" name="ctl00$commonForm$ctl00$ctl00$listCheck$1" checked="checked" type="checkbox"><label for="ctl00_commonForm_ctl00_ctl00_listCheck_1">Amount</label>
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
    </tr>
</table>

我尝试了<代码>$(原文)。 #list > content , but it don t work. 我不熟悉 j。 感谢!

最佳回答

这是我认为有必要的 j:

// When the select link is clicked
$( #selectall ).click( function ( ) {
   \ For each checkbox inside an element with class "link" set to checked
    $( .list input[type=checkbox] ).attr( checked , checked );
});

你们需要改变与这一点的联系:

<a id="selectall" href="javascript:void( );">Select all</a>

同样,为了当选,j Query:

$( #deselectall ).click( function ( ) {
    $( .list input[type=checkbox] ).removeAttr( checked );
});

联系:

<a id="deselectall" href="javascript:void( );">Select all</a>

由于这将伤害我,我不得不警告不要使用表格来填写表格。 几天来,这种做法非常坏,你可以做一看好,但更灵活,使用干.和特别安全局。 页: 1

<div id="select_links">
    <!-- Anchor to click -->
    <a id="selectall" href="javascript:void( );">Select all</a>
    <a id="deselectall" href="javascript:void( );">Deselect all</a>
</div>
<div class="list">
    <div class="listItem">
        <input id="ctl00_commonForm_ctl00_ctl00_listCheck_0"
               name="ctl00$commonForm$ctl00$ctl00$listCheck$0" checked="checked"
               type="checkbox">
               <label for="ctl00_commonForm_ctl00_ctl00_listCheck_0">Date</label>
    </div>
    <div class="listItem">
        <input id="ctl00_commonForm_ctl00_ctl00_listCheck_1"
               name="ctl00$commonForm$ctl00$ctl00$listCheck$1" checked="checked"
               type="checkbox">
        <label for="ctl00_commonForm_ctl00_ctl00_listCheck_1">Amount</label>
    </div>
</div>

EDIT: Mark s right, that should have been removeAttr(checked), not attr(ecked ,null);

问题回答

简言之,它只是针对所有检查箱和设置检查箱。

$("#doIt").click(function(){
    $("input[type= checkbox ]").attr("checked", true);
});

如果你想要取消检查

$("#doIt").click(function(){
    $("input[type= checkbox ]").removeAttr("checked");
});

另一种选择是使用<代码>toggle(<>t/code>,可用于在外盘上锁箱。

$("#doIt").toggle(function() {
    $(this).text("Select All");
    $("input[type= checkbox ]").removeAttr("checked");

}, function() {
    $(this).text("Deselect All");
    $("input[type= checkbox ]").attr("checked", true);
});

www.un.org/Depts/DGACM/index_spanish.htm http://jsfiddle.net/markcoleman/rncmx/1/“rel=“nofollow”>jsfiddle

I would remove any dhtml code from your anchor tag, get rid of the onclick and change the href to just #. With jquery all you need is a class or id.

阁下:

页: 1

<a id="select_on" class="toggle_checks" href="#">Select all</a>
<a class="toggle_checks" href="#">Select none</a>

页: 1

$( a.toggle_checks ).click(function(){
   $( table.list ).children( input ).attr( checked , this.id ==  select_on );
});

因此,该法典正在用美元(a.toggle_checks)选择所有固定的标签,并用类别对_进行约束,在点击事件手上,用类别清单选定表格(表.list )。





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

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签