选择所有复选框命令jQuery,JavaScript [英] select all checkboxes command jquery, javascript

查看:60
本文介绍了选择所有复选框命令jQuery,JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在单击链接时选中所有复选框

I'm trying to get all of my checkboxes to be checked when clicking a link

看起来像这样:<a href='javascript:;' onclick="$.overall.selectAll();">select all</a>

循环输入:<input type="checkbox" name="delete[$i]" value="1" />

jquery代码:

var checked_status = this.checked;

    $("input[name=delete]").each(function() {
    this.checked = checked_status;
});

有人可以帮我检查一下吗??

Can someone help me get it to check all.. ?

单击全选"链接时,似乎什么都没有发生.(甚至没有错误)

When clicking at the select all link, nothing seems to happen.. (not even an error)

推荐答案

尝试以下操作.

已更新.该处理程序绑定到锚点,因此将没有this.checked属性可用.

Updated. The handler is tied to an anchor therefore there will be no this.checked attribute available.

$("#select_all").click(function(){
    $("input[name^=delete]").attr('checked',  'checked');  
});

这篇关于选择所有复选框命令jQuery,JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆