val() of Input in div
val() of Input in div
Dear Jquery Users, I have a question.
I have a while loop like this e.g.
- <div id="commentbox">
- <?php echo $code; ?>
- <input type="hidden" value="<?php echo $id; ?>
- <a href="#" id="clicktodo">Show Comment</a>
- </div>
So this is being repeated 8 times and everytime the id in the hidden input changes.
My question is, how can I tell JQuery to access the input which is in the div, as the clicked <a>.
So to make it clear:
When I click at the <a> in the 6th commentbox div, I want Jquery to get the value of the hidden input in the 6th. commentbox div.
At the moment, I added a var $i which increases, and so I built up following code, and reapeted it 8 times, with just another number:
- $("#comments1 a#commentclick").button()
.click(function() {
var ID = $("#comments1 #entrieID").val();
$("#commentbox1 #commentinner").fadeOut(200, function() {
$(this).remove();
});
$.ajax({
url: 'comments.php',
type: 'GET',
data: 'ID=' + ID,
success: function(result) {
$('#commentbox1').append(result);
}
});
});
Brgds,
Mehmet Akdag