4/06/2010

Add a css Class Using Jquery

To use Css Class in an HTML Tag we can use a Jquery function addClass(). This function add a css class into your HTML tag.The most intresting things is that you can use this class on a eventhandler also, To get effects when a client/user response on it.
This is an example to add a css class into a Html Tag

<script type="text/javascript">
$(document).ready(function(){
$('.click').click(function(){
$('p').addClass('green');
});
});
</script>
<style type="text/css">
.green{ color:green;}
</style>

Write this code into your body tag
<button class="click">Click Me</button>

10 comments:

  1. The article is really good if u ask my rating for this article for 5 out 5 I will shurely give 4 Ratings Because the article contains maximum required information about how to Add a css Class Using Jquery which really helps any one if they come across this article for information

    ReplyDelete
  2. JavaScript is a programming language used to develop dynamic websites which run at the client side. This means that the language will not execute at the server but will run with your web page on the browser of the user. It is often used to manage online advertisements, validation of forms, and check on the ID of the browser. It doesn't conflict with other languages such as PHP or ASP when you design a website.
    Features

    ReplyDelete
  3. jQuery also provides capabilities for developers to create plugins on top of the JavaScript library. Providing this option, developers are able to create abstractions for low-level interaction and animation, advanced effects and high-level, theme-able widgets. This contributes to the creation of powerful and dynamic web pages.

    ReplyDelete
  4. This would be very useful for me because I don't know how to add Css class to the HTML tag that I am working on. I will try to use this from now on.

    ReplyDelete
  5. Its hard foe me to learn script..you gave a great tips and tricks here! nice works

    ReplyDelete
  6. I want to ask, why the code is not working in my wordpress blog. I've followed the steps above, where the error? I use wordpress.com.

    ReplyDelete
  7. I plan on starting a website soon and I need a good book that can teach me advanced XHTML & CSS. I already kno the basics pretty well, and I want a book that really gets to advanced stuff. I also wish to learn PHP, MySQL, and JavaScript. So I was hooping if anyone could recommend some good books for learning them. The article is really good.

    ReplyDelete
  8. The article is really good if u ask my rating for this article for 5 out 5 I will shurely give 4 RatingsJavaScript is a programming language used to develop dynamic websites which run at the client side.This contributes to the creation of powerful and dynamic web pages.

    ReplyDelete
  9. hey its a very nice article . very easy to understand .thanks alot . i need a favour ,can please explain the hyperlinking with above context ? :)
    waiting for new articles to come .

    ReplyDelete
  10. hey nice article but i don't know about this much your article has introduced me to this thing but i think dreamweaver is used in place of these HTML etc. am i right??

    ReplyDelete