I am new to JQuery and I have a very basic question about this.
I have two html table elements, one with id="needColor" and another one without id.
I want to set the background color of an even row on the table with id = "needColor" but not on the table without any id.
How can I do this with the JQuery?
The current code is as follows:
<script src="http://ift.tt/1XwG72U"</script>
<script>
$(document).ready(function(){
//tried to add something like these, but I am not sure how it must be written
// this makes all the even row in "all" table to be yellow
$("tr:even").css("background-color", "yellow");
// this will give the whole yellow color of table with id = needColor
$("table[id='needColor']").css("background-color", "yellow"); // do not use ("#needColor") as this will affect other elements than "table"
});
</script>
Thanks.
Aucun commentaire:
Enregistrer un commentaire