js實(shí)現(xiàn)復(fù)選框全選反選 jquery怎么實(shí)現(xiàn)全選復(fù)選框?
jquery怎么實(shí)現(xiàn)全選復(fù)選框?1. 為所有復(fù)選框定義一個(gè)ID,例如:<input type=“checkbox”ID=“cball”value=“all”>2。為其他復(fù)選框定義相同的名稱,例
jquery怎么實(shí)現(xiàn)全選復(fù)選框?
1. 為所有復(fù)選框定義一個(gè)ID,例如:
<input type=“checkbox”ID=“cball”value=“all”>
2。為其他復(fù)選框定義相同的名稱,例如:
愛好:<input type=“checkbox”name=“cbhobby”value=“song”> singing<input type=“checkbox”name=“cbhobby”value=“dance”> dancing<input type=“checkbox”name=“cbhobby”value=“play”> play games<;input type=“checkbox”name=“cbhobby”value=“eat”<;input type=“checkbox”name=“cbhobby”value=“sleep”>
3。編寫jQuery代碼,使復(fù)選框的選定屬性與單擊“全部”框時(shí)復(fù)選框的選定屬性一致
<;script type=“text/JavaScript”src=“js/jQuery.1.8.3。最小js“></script><script type=”text/javascript“>$(function(){$(”cbAll“)。單擊(function(){$(”input[name=”cbHobby“]”).prop(”checked“,$(this).prop(”checked“)})</script>”