Sunday, 26 March 2017

jQuery id Selector

  • The id selector selects the element with specific id in html. 
  • It is work same as function as document.getelementbyid() in JavaScript
  • jQuery selectors start with the dollar sign and parentheses().

ex:
$("#id") 


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("#intro").css("background-color", "red");
});
</script>
</head>
<body>

<h1>Home</h1>
<p id="intro">This paragrap apply jquery css</p>
<p>This paragrap without css</p>
</body>
</html>


Output:


No comments:

Post a Comment

Thank you for comment