jqueryでは変数を$()のid値として使用します

776 ワード

jqueryはidの書き方として変数を使用します.


	
		
		
		<script type="text/javascript" src="jquery.js"/>
	
		
	
		<div id="company" style="width: 200px;height: 200px;"/>
	
	<script>
		var a = "company";//     
		$("#"+a).html(111);//   a  id   #  
	</script>
</code></pre> 
  <br/> 
  <strong>      (position       ,  EL      id  ):</strong> 
   
  <pre><code><script>
		$("#"+'${position}').html(111);//   a  id   #  
	</script></code></pre> 
  <br/> 
  <br/> 
 </div> 
</div>
                            </div>
                        </div>