Tag: apply css in all childs of parent

How can we apply css in all childs of parent node in jquery?

December 26, 2009 | Filed Under JQuery | Leave a Comment

Suppose that  we are working on <table>
so  all <td> of table will be the child of <tr>

To apply css  on all <td> we need to follow below code
Include JQuery library

<script src=”http://code.jquery.com/jquery-latest.js”></script>

Write below code in head section of web page

  <script>
  $(document).ready(function(){
    $("tr:first").css("font-style", "italic");
  });
</script>
 <style>
  td { color:blue; font-weight:bold; }
  </style>
Above code will  apply font-style:italic in all <td>'s data.
Article written by urooj

© PHPInterviewQuestion.com 2009 - 2010

eXTReMe Tracker