当前位置:编程学习 > JAVA >>

jquery问题

$("#$(this).attr('class')").attr("checked", true);


我现在想改变某一class的checkbox中第一个对象checked属性

但是这个class对象名字我是用动态获取的,用$(this).attr('class')获取

但是现在就是不能用
$("#$(this).attr('class')").attr("checked", true);
这种方法 --------------------编程问答-------------------- $("#$(this).attr('class')").attr("checked", true);
至少也应该是
var id = "#" + $(this).attr('class');
$(id).attr("checked", true);

可以试一下,不一定正确 --------------------编程问答-------------------- 没明白,你都已经用this关键字了,为什么还用这么麻烦,直接$(this).attr("checked",true);不就好了 --------------------编程问答--------------------
$("#"+$(this).attr('class')).attr("checked", true);
--------------------编程问答-------------------- LS们貌似都误解了LZ的需求
#+id这种方式是用来获取id属性为id值的所有标签
LZ的需求应该是获取class属性为指定名称的第一个标签,如下:
$('.'+$(this).attr('class')+':checkbox').first(); --------------------编程问答-------------------- .attr("checked", “checked"),别用true,试试这样
补充:Java ,  Web 开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,