Monday, December 14, 2009

CSS change children with JQuery

I wanted to be able to change the children's css of an element with JQuery.

In a table, for instance, I wanted to change the data rows as the user's mouse and . I was using
$("#tr").mouseleave(function(){
$(this).children().css = "...";
});

This even changed rows that were header rows.

I had more than one table on the page, so accessing an id isn't efficient or practical.

I created a class in css, tableHead, and set the rows containing the th to this class.

Then in JQuery, after $(this).children().css = "";

$(".tableHead").children().css = "..";

This changed everything with the class "tableHead" to the new css.

No comments:

Post a Comment