Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Selecting elements with Jquery | styling html elements with Jquery


To Select an element in Jquery we simply pass the element’s name as a string parameter to the $ function (note the $ symbol is the short form for Jquery). Here is how the code will look





</head>
<script type="text/javascript" src="Scripts/jquery-1.7.2.min.js"></script>
</head>

<body>
<script type="text/javascript">
$(document).ready(function() {
$('h1').click(function(){
$(this).css('background-color','#F00')//setting a Background color
$(this).css('color','#fff') // setting font solor
});//click function end
});//document ready function end
</script>

<h1>click me and change the Background</h1>

<style>
h1{ border: 1px solid #999; border-radius:5px; width:510px; cursor: pointer;}
</style>
</body>
</html>


This post first appeared on Web Development FAQs, please read the originial post: here

Share the post

Selecting elements with Jquery | styling html elements with Jquery

×

Subscribe to Web Development Faqs

Get updates delivered right to your inbox!

Thank you for your subscription

×