Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

jitendra-jquery

<html>
   <head>
      <title>The JQuery Example</title>
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
		
      <script type = "text/javascript" language = "javascript">
         $(document).ready(function() {
         
         var html="";  
         
           $("#btnClick").click(function(){
           var $li= $("#ulist li").filter(".li");
           alert($li.length);
           if($li.length>0)
           {
            $li.each(function(){
               html+= "<li>"+$(this).text()+"</li>";
           });
           }
           else
           {
               html+= "No Element found";
           }
           
            $("#message").append(html);
           });
         });
      </script>
		
     
   </head>
	
   <body>
     <h3>Filter Vs find</h3>  
<ul id="ulist">  
<li id="li1" class="li"> Apple</li>  
<li id="li2" class="li">Orange</li>  
<li id="li3"> Grapes </li>  
</ul>  
  
<h4>Output</h4>  
<ul id="message">  
</ul>  
<br/>  
<button id="btnClick">Click Me</button> 
   </body>
</html>

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.