Jquery filter() with class - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:filter

Description

Jquery filter() with class

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  www  . j a  v a2s  .  co m
var result = $("h1");
var outcome = $(result).filter('.locate');
if(outcome.length > 0){
    $("#result").text("found it");
} else {
    $("#result").text("didn't find it");
}
    });

      </script> 
 </head> 
 <body> 
  <h1 id="test" class="locate">About Me</h1> 
  <h2 id="result"></h2>  
 </body>
</html>

Related Tutorials