I’m using a function to display a table of data on a page (from an array that’ll be linked), and using jquery to alternate the background-color of the rows.
Readers will then have the option to search the data (not important here) and then to reload the original data. But when the original showAll() function is called from a click event, jQuery doesn’t apply the background colors at all.
Any suggestions as to how to ‘re-awaken’ jQuery the second time the showAll() function gets called.
Thanks - code below:
<html><head><title>Test</title>
<script src="http://i.cmpnet.com/channelweb/javascript/jquery/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".datarow:nth-child(even)").css("backgroundColor","#ccff00");
$(".datarow:nth-child(odd)").css("backgroundColor","#ccffff");
});
</script>
<script type="text/javascript">
function showAll() {
var newcode = "";
for (i=1; i<7; i++) {
newcode = newcode + "<div class='datarow'>Data Here<\\/div>";
}
document.getElementById('datas').innerHTML = newcode;
}
</script>
</head>
<body bgcolor="ffffff">
<form><input type="button" value="Show All" onClick="showAll()"></input></form>
<div id="datas" style="width: 300px; height: 400px; "></div>
<script language="javascript" type="text/javascript">showAll();</script>
</body></html>