I'm adding record to table with ajax button. I want to use zebra table. I have a jquery function for zebra table.
<script type="text/javascript">
$(function() {
$("table tr:nth-child(even)").addClass("zebraTable");
});
</script>
CSS:
.zebraTable {background-color: #F2F2F2}
When I call on click of normal button, it works like zebra table. but when I change button with ajax button, table turns normal table. Do you have any idea?
The answer depends on what has happened to the table since you added the zebraTable class to the rows. I'm assuming your Ajax call is modifying the table (replacing it, adding/removing rows, hiding/showing rows, etc.)?
Just be aware that the tr objects in your DOM will retain that class unless you remove it and that the selector is applied to both hidden and visible tr objects. My suggestion would be to remove the zebraTable class from all rows and then re-apply it (and adjust for hidden tr objects if you have them).