Jquery經常使用選擇器

<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>

  <script type="text/javascript" src="jquery-2.0.3.min.js"> </script>

 </head>
 <body>
  

<div>
	<div id="content">
		<span>
			<a href="#">123123<a>
		</span>
		<ul>
			<li></li>
			<li></li>
			<li></li>
		</ul>
	</div>


	<select id="mySelect">
		<option value="1">1</option>
		<option value="2">2</option>
		<option value="3">3</option>
		<option value="4">4</option>
	</select>

</div>




<div class="radio clearfix inscomeTJType" id="inscomeTJType">
                        
	  <label style="display: inline-block; padding:0 10px 10px 0;">
		<input type="checkbox" checked="checked" data-id="13" name="type">
		<span class="text">地圖</span>&nbsp;&nbsp; 
	  </label>
														  
	<label style="display: inline-block; padding:0 10px 10px 0;">
		<input type="checkbox" checked="checked" data-id="14" name="type">
		<span class="text">短信1</span>&nbsp;&nbsp; 
	</label>
																					 
	<label style="display: inline-block; padding:0 10px 10px 0;">
		<input type="checkbox" data-id="15" name="type">
		<span class="text">鋼聯數據</span>&nbsp;&nbsp; 
	</label>
																					  
	  <label style="display: inline-block; padding:0 10px 10px 0;">
		<input type="checkbox" data-id="22" name="type">
		<span class="text">境外拓展</span>&nbsp;&nbsp; 
	  </label>																	 
														
</div>






<script type="text/javascript">
<!--

$(function(){
	$('#content').find('span').find('a').on('click',function(){
		console.debug($(this));
	});

	//等同以下
	$('#content span a').on('click',function(){
		console.debug($(this))
	});

	//獲取選中的option
	$('#mySelect').on('change',function(e){
		var value = $('#mySelect option:selected').val();
	});


	$("#inscomeTJType input[type='checkbox']:checked").each(function(index,ele){
		console.debug(index)
		console.debug(ele)
		console.debug($(this).data('id'))
	})

})




//-->
</script>


 </body>
</html>
相關文章
相關標籤/搜索