Add Class To Closest Element by selecting last element - Javascript jQuery Selector

Javascript examples for jQuery Selector:class

Description

Add Class To Closest Element by selecting last element

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">

      </script> 
   </head> 
   <body> 
      <span>test</span> 
      <script>
    console.log($('span:last').text());

      </script> 
      <span>Not me</span>  
   </body>//from  w ww  . java 2s.co  m
</html>

Related Tutorials