jQuery noob here, trying to produce alternating row background colors. This works in HTML:
<script type="text/javascript">
$(document).ready(function() {
$('.stripedtable tr:even td').addClass(" evenrow");
alert("Just executed stripedtable jQuery in MasterPage");
});
</script>
The "evenrow" class is added to the 's class, for even rows only. Great!
Except when I put it into an ASP.NET MasterPage, the "evenrow" class is never added. In FireBug, I confirm that the function is being executed and jQuery is there. The alert()
indicates that the method is firing after the page is loaded. No "evenrow" class, though, and not stripes.
It's probably relevant that the table that is NOT being altered as I'd like, is generated by a UserControl on a page that inherits from the MasterPage.
This is weird. When I go to View Source, copy the entire source to NoStripes.html, and open the HTML page in a browser, I get the "evenrow" class and the stripes. jQuery works fine.
This seems to imply that (somehow) the HTML is not really there, when the method fires from the MasterPage? So jQuery can't modify it?! And the HTML IS there, with NoStripes.html, because I saved the generated source?!
I tried putting the $('.stripedtable etc) on a content placeholder on the UserControl. The alert()
shows it firing. No stripes.
Suggestions? I've googled at length without finding a solution. It's probably something simple, but I can't figure it out.
TIA - Hoytster