I am having trouble coming up with a jQuery script that will all content of a div if there are no unordered list items present. So if there are unordered list items inside of the div then the div will be displayed, otherwise it will be hidden.
here is the basic html I have to test this:
<html>
<title>Experiment Fix Div Hidding</title
<head>
<link rel="stylesheet" type="text/css" href="css/css.css" media="all"/>
<script src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/scripts.js"></script>
</head>
<body>
<table>
<tr>
<td>
<div id="contenFirst">Sample Content. Not display if not bullets points exists
<ul>
<li><a href="#">Hello world</a></li>
<li><a href="#">Hello world2</a></li></ul></div>
</td>
</tr>
</table>
</body>
</html>
Here is the script I have come up with so far, but it doesn't seem to do the job:
$(document).ready(function(){
// hiding a div based on it not having any content (unordered list items)
if($("#contentFirst").html().length == 0){
$("#contentFirst").hide();
}
});
I am going in the right way with the jquery script, haven't done much with jquery before.
Any suggestions will be greatly appreciated.