Javascript examples for jQuery Selector:id
Get element with certain ID using .is() method
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.js"></script> <script type="text/javascript"> $(window).load(function(){//from w w w. jav a 2 s . c om $( document ).ready(function() { var id = "foo"; if($("div").is("#" + id)) console.log($("div").text()); }); }); </script> </head> <body> <div id="foo"> Some text </div> </body> </html>