How to query next element from current element using jQuery!!
Hello Experts,
How to query a next particular element from current element?
Here is an example...
I have a 3 radio buttons inside table. Each row has a radio button.
After table tag, i have a textarea element.
When User select any radio button, I need to hide/show the textarea control based on value of the Radio button.
Below code is not working as expected. Please help me with this problem.
Please find the attached code for your review.
- <html>
<head>
<script language="javascript" src="http://code.jquery.com/jquery-1.4.2.js"></script>
</head>
<body>
<li>Question???
<table id="ctl00_ContentPlaceHolder1_ucQuestion_CtrlRepeater_ctl02_ctl11_ctl03_ctl00"
border="0">
<tr>
<td>
<input id="ctl00_ContentPlaceHolder1_ucQuestion_CtrlRepeater_ctl02_ctl11_ctl03_ctl00_0"
type="radio" name="ctl00$ContentPlaceHolder1$ucQuestion$CtrlRepeater$ctl02$ctl11$ctl03$ctl00"
value="1" /><label for="ctl00_ContentPlaceHolder1_ucQuestion_CtrlRepeater_ctl02_ctl11_ctl03_ctl00_0">Yes</label></td>
<td>
<input id="ctl00_ContentPlaceHolder1_ucQuestion_CtrlRepeater_ctl02_ctl11_ctl03_ctl00_1"
type="radio" name="ctl00$ContentPlaceHolder1$ucQuestion$CtrlRepeater$ctl02$ctl11$ctl03$ctl00"
value="2" /><label for="ctl00_ContentPlaceHolder1_ucQuestion_CtrlRepeater_ctl02_ctl11_ctl03_ctl00_1">No</label></td>
<td>
<input id="ctl00_ContentPlaceHolder1_ucQuestion_CtrlRepeater_ctl02_ctl11_ctl03_ctl00_2"
type="radio" name="ctl00$ContentPlaceHolder1$ucQuestion$CtrlRepeater$ctl02$ctl11$ctl03$ctl00"
value="3" /><label for="ctl00_ContentPlaceHolder1_ucQuestion_CtrlRepeater_ctl02_ctl11_ctl03_ctl00_2">N/A</label></td>
</tr>
</table>
<textarea name="ctl00$ContentPlaceHolder1$ucQuestion$CtrlRepeater$ctl02$ctl11$ctl03$ctl01"
rows="3" cols="80" class="commentscls"></textarea><br />
<br />
</li>
</body>
</html>
<script language="javascript">
$(document).ready(function() {
$('textarea').hide();
$(':radio').click(function() {
if (this.value == "3") {
$(this).next('textarea').show(); // This is not working
alert('hi debugger')
} else {
$(this).next('textarea').hide(); // This is not working
}
});
});
</script>
Regards,
TK