I have 20 fields that are created (numbered 1-20) with corresponding submit buttons. I need to retrieve the values of those fields for an AJAX post depending on which button number was clicked. For example:
$(function(){
$("#addCommentButton1").click(function(event) {
var trackid = $("#trackidField1").val();
var comment = $("#addcommentfield1").val();
$(function(){
$("#addCommentButton2").click(function(event) {
var trackid = $("#trackidField2").val();
var comment = $("#addcommentfield2").val();
I’m hoping there is an easier way to do this than writing the function 20 times.
Thanks!
$(function(){
$(".addCommentsExpBtn").click(function(event) {
var container = $(this).closest(".songPost");
container.find('.addCommentsExp').slideToggle();
});
});
you can do like this,
and jquery,