Access dynamic generated div id, with ^ - Javascript jQuery Selector

Javascript examples for jQuery Selector:id

Description

Access dynamic generated div id, with ^

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.8.3.js"></script> 
  <script type="text/javascript">
$(document).ready(function() {
    $('div[id^="a"]').css("background-color", "blue");
});//from  w  ww .  j a va  2  s.  c o  m

      </script> 
 </head> 
 <body> 
  <div id="a1">
    A1 
  </div> 
  <span id="a2">A2</span> 
  <div id="a3">
    A3 
  </div> 
  <div id="BB">
    BB 
  </div>  
 </body>
</html>

Related Tutorials