Find elements or its attributes - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:attr

Description

Find elements or its attributes

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://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
   </head> 
   <body> 
      <h1 class="test1"> </h1>
      <h1 id="test" class="test2"> 
         <script type="text/javascript">
console.log($('.test1').attr('id'));
console.log($('.test2').attr('id'));

         </script>  
      </h1>
   </body>//from  w ww .j a v a 2s  . c om
</html>

Related Tutorials