
when I take value from dress, but jquery display value from shoes, what jquery selector for solve my problem? before i use code :
$(document).delegate(".product", "submit", function(){
alert($(".name").val());
return false;
});

when I take value from dress, but jquery display value from shoes, what jquery selector for solve my problem? before i use code :
$(document).delegate(".product", "submit", function(){
alert($(".name").val());
return false;
});
The problem is that .name is a class selector and will find multiple instances. Then when you call .val() it will get the first instance value only. You need to be more specific, I would suggest making use of this (which will be the form) and then finding the .name element within that form (which looks like it will be a unique combination). Something like this:
$(document).delegate(".product", "submit", function(){
var $form = $(this);//get the current form being submitted
var $name = $form.find(".name");//find the name element relative to the form
alert($name.val());//alert the correct relative name value
return false;
});
NOTE: delegate has been superseded by the on method as of JQuery 1.7. Which you would use like so:
$(".product").on("submit", function(){
//code
}