Jquery use any select box ID starting with - Javascript jQuery Selector

Javascript examples for jQuery Selector:id

Description

Jquery use any select box ID starting 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.9.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//from  w  ww.j av a 2  s.c  o  m
$("select").change(function(){
  var n=$(this).attr("id").split("_");
  if(n == "select")
  {
     console.log("do something here");
  }
});
    });

      </script> 
 </head> 
 <body> 
  <select type="select" id="select_123"> <option>One</option> <option>Two</option> </select>  
 </body>
</html>

Related Tutorials