You will run into problems when ID'ing 2 list items as the same ID. If you want the same CSS to apply to both, use classes instead.
patricksweeney
2009-02-09 04:41:57
You will run into problems when ID'ing 2 list items as the same ID. If you want the same CSS to apply to both, use classes instead.
$("li:first").click(function() {
$(this).children("div").hide();
});
Having two identical IDs is invalid xHTML
Not sure about the exact jQuery syntax
but in sudo code would be something like:
li1 addEvent('click')
{
get child of li1, filter by class c1
set style on child(display, none)
}
this might work for you:
note: make sure you include the jquery.js, i was lazy and didnt put it in here.
<html>
<head>
<script type="text/javascript" language="javascript">
$(document).ready(function(){
$(".clickableLI").click(function(){
$(this).find("div").hide();
});
});
</script>
</head>
<body>
<ul>
<li class="clickableLI">
<div class="c1"></div>
</li>
<li class="clickableLI">
<div class="c1"></div>
</li>
<ul>
</body>
</html>