I have the following code:
$("#add-button").click( function(add_color) {
$.each( $("input[name='color[]']"), function () {
if( color_selected == $(this).val() )
{
alert( "Color already choosen" );
return false;
}
});
alert("Here is the end of add-button");
});
I need to stop the code if return false is called, but the JQuery is stopping only the $.each method.
I used “Event.stop(add_color)” instead of “return false” and it works, but i don’t know if this is correct.
Anybody can help me?
You could always do this:
Event.stop is usually okay, though.