radio 標簽狀態改變時 觸發事件


<html>
<head>
<script src="jquery1.7.2.js"></script>


</head>

<body>
	<div id="div_pathType">
	
	<input name="pathType" class="page_input_radio" id="pathType" type="radio" checked="" value="1">路徑1
	
	<input name="pathType" class="page_input_radio" id="pathType" type="radio" value="2">路徑2

	</div>


</body>

<script type="text/javascript">

//第一種方法: jquery 的形式(對頁面所有的radio有效):
// $(':radio').click(function(){
//	var checkValue = $(this).val(); 
//	alert(checkValue);
// });

//第二種方法: jquery 的形式(針對name="pathType" 的radio 有效):
$('input:radio[name="pathType"]').click(function(){
	var checkValue = $('input:radio[name="pathType"]:checked').val(); 
	alert(checkValue);
});

/* 第三種方法: js 的形式:
var pathTypeArr = document.getElementsByName("pathType");

pathTypeArr[0].onclick=function(){
	
	var checkValue = pathTypeArr[0].value;
	
	alert(checkValue);

};
pathTypeArr[1].onclick=function(){
	
	var checkValue = pathTypeArr[1].value;
	
	alert(checkValue);

};

*/

</script>
</html>

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM