How do I process PHP generated content with Jquery?
I Have a PHP script that generates a list element for every entry in a MySQL database. I am trying to use the jquery :odd selector on these list elements to change the background color of every 开发者_JAVA技巧other list element. It thus far hasn't worked and i think that the JS is either running before the PHP parses or some other scenario I am not aware of is causing the JS to not execute the manipulation I am trying to achieve.
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("li:odd").css("background-color", "#000");
}
</script>
<ul id="datalist">
<?php while ($row = mysql_fetch_array($query))
{
echo "<li><br/>".$row['FName']." ".$row['LName']."<br/> Phone: ".$row['PHON']."<br/> Workstation: ".$row['EQUIP']."<br/></li>";
}
?>
</ul>
Note: This isnt the entire page just the relevant code to my question.
You missed a )
at the end of your Javascript (to close the $(document).ready(
call)
精彩评论