href attribute selector – jQuery


$(“[href]”) – selector is used to select the all elements which have attribute “href”.


Syntax : href attribute selector

href attribute selector – jQuery Example

<!DOCTYPE html>
<html>
<head>
<title>href attribute selector - jQuery Example</title>
 <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js">
 </script>
<script type="text/javascript">
         $(document).ready(function(){
         $("#demo").click(function(){
          $("[href]").css("border","4px solid red");
          $("[href]").css("color","blue");
          $("[href]").css("font-size","26px");
          });
          });
</script> 
  
</head>	
<body>
<a href="javascript:void(0)" id="demo"> 
Click Me
</a>
<ol>
  <li> <a href="javascript:void(0)">First Item</a> </li>
  <li> <a href="javascript:void(0)">Second Item </a></li>
  <li> <a href="javascript:void(0)">Third Item </a></li>
</ol>
</body>
</html>             

Try it »


Advertisements

Add Comment

📖 Read More