.next() function [Solved]
Hi
It seems that the next function only works when the sibling immediately preceeds.
What I'm trying to do is to get the next "note" class text when any "ojo" class is clicked even if it is not immediately next to it:
Eg:
-
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="JavaScript" src="jquery.js"></script>
<script language="JavaScript">
$(document).ready(function() {
$(".ojo").click(function() {
alert($(this).parent().next(".note").text())
})
})
</script>
</head>
<body>
<p class="ojo">aaa <-------Can this one
<p class="ojo">aaa
<p class="ojo">aaa
<p class="ojo">aaa <-------only works with this one
<div class="note">bbb</div> <-------Get the text of this one
<p class="ojo">ccc
<div class="note">ddd</div>
<p class="ojo">eee
<div class="note">fff</div>
<p class="ojo">ggg
<div class="note">hhh</div>
</body>
Any help or suggestion very welcome
Thanks
Ward