label 与 input

<form onsubmit="return checkform()" >
<div style=" 100%; border:0px #000 solid; float:left;">

<label for="a1"><div style=" 300px; height:300px; border:1px #cccccc solid;">11</div></label>
<input type="radio"  name="a" id="a1" checked="checked" value="ddddd" />

<label for="a2"><div style=" 300px; height:300px; border:1px #6CF solid;">22</div></label>
<input type="radio" name="a" id="a2"  value="adsfasd"/>

</div>
</form>

  今天做了单选的样式自定义效果,但是无奈label关联不到input的checked,依然是天地会的群友帮助了我,非常感谢。以此记录。

$("label").mouseover(function(){
	alert($('#'+$(this).attr('for'))[0].checked)
})

  

原文地址:https://www.cnblogs.com/wqing/p/3896866.html