Use a variable in a jQuery selector - Javascript jQuery

Javascript examples for jQuery:Tag Traversing

Description

Use a variable in a jQuery selector

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.7.1.js"></script> 
      <script type="text/javascript">
$(document).ready(function()
{
   var myID="123";
    $("#das_"+myID).html("Changed!");
});//w  w w.  j a  v a2s .  com

      </script> 
   </head> 
   <body> 
      <div id="das_123">
         content
      </div>  
   </body>
</html>

Related Tutorials