首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

checkbox仿照radio

2012-11-22 
checkbox模仿radiohtmlheadmeta charsetUTF-8titlecheckbox模拟radio/titlescript typete

checkbox模仿radio

<html><head><meta charset="UTF-8"><title>checkbox模拟radio</title><script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script><script type="text/javascript">$(function(){$('form input[type=checkbox]').click(function(){    var checkboxs = $('form input[type=checkbox]');    checkboxs.each(function(){        $(this).attr('checked', false);    });    $(this).attr('checked', true);});        });</script></head><body><form name="form1" id="form" method="post" action=""><input type="checkbox" name="a" /><input type="checkbox" name="b" /></form></body></html> 
?

用复选框模仿单选框实现效果,Jquery控制,

其中each()是获取全部的复选框,使他们成未选中状态,只有点击的这个复选框是选中状态。

?

热点排行