Ali*_*sam 1 html javascript checkbox jquery
HTML代码:
<div class="checkbox" style=" float:left "></div>
<input type="checkbox" class="realcheckbox" id="financing" />
Run Code Online (Sandbox Code Playgroud)
jQuery代码:
$(".checkbox").click(function() {
var xchecked = $(this).siblings(".realcheckbox").attr("checked");
if (xchecked == false) {
$(this).css("background-image","url('checkboxselected.png')");
$(this).next(".realcheckbox").attr("checked",true);
}
else {
$(this).css("background-image","url('checkbox.png')");
$(this).next(".realcheckbox").attr("checked",false);
}
});
Run Code Online (Sandbox Code Playgroud)
点击假复选框不会检查真实的复选框,但是如果检查了真实的复选框,点击假的那个正在完成工作,意味着真正的一个未经检查,第一个有什么问题?
演示 http://jsfiddle.net/ktwDK/3/
好读:http://api.jquery.com/checked-selector/
.is(":checked") 会为你做的伎俩.
jquery代码
$(".realcheckbox").click(function(){
alert($(this).is(":checked"));
});?
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
572 次 |
| 最近记录: |