$(document).ready(function(){
$("#cr").click(function(){
if(this.checked){ //DOM方式判断
alert("感谢你的支持!你可以继续操作!");
}
})
});为什么这样写不对呢
$(this)
if($(this).checked){ //DOM方式判断
alert("感谢你的支持!你可以继续操作!");
}
为什么这样写不对呢
$("#cr").click(function(){
if(this.checked){ //DOM方式判断
alert("感谢你的支持!你可以继续操作!");
}
})
});为什么这样写不对呢
$(this)
if($(this).checked){ //DOM方式判断
alert("感谢你的支持!你可以继续操作!");
}
为什么这样写不对呢
$(this) 则返回一个jQuery 对象,后者对dom对象进行了包装,所有的操作都要另外按jQuery的方法进行.
$(document).ready(function () {
$("#cr").click(function () {
if (this.checked) { //DOM方式判断
alert("感谢你的支持!你可以继续操作!");
}
})
});
$(document).ready(function () {
$("#cr").click(function () {
if ($(this).attr("checked")) { //Jquery方式判断
alert("感谢你的支持!你可以继续操作!");
}
})
});
$(document).ready(function () {
$("#cr").click(function () {
if ($(this)get(0).checked)){ //DOM方式判断 $(this)[0],$(this).get(0) Jquery对象转成DOM
alert("感谢你的支持!你可以继续操作!");
}
})
});
$(document).ready(function () {
$("#cr").click(function () {
if ($(this).get(0).checked){ //DOM方式判断 $(this)[0],$(this).get(0) Jquery对象转成DOM
alert("感谢你的支持!你可以继续操作!");
}
})
});上面那个 漏了 。