jQuery select box if option 1 is selected
-
14-11-2019 - |
سؤال
I have a problem writing a script that will prevent default behavior of submit button when option 1 from select box is selected. Here's the code:
Also on my website I'm using skinnable-select plugin but I don't know if that has any impact on the script. We'll be grateful for any help.
المحلول
Try this: http://jsfiddle.net/QgZHC/7/
نصائح أخرى
$('.send').click(function(e) {
if ($('.dupa').val() == '2') {
alert('Dupa');
e.preventDefault();
}
});
Try this:
if ($('.dupa').attr('value') != 1)
try
$('.send').click(function(e) {
if ($('.dupa option:selected').val()==1) {
alert('Dupa');
e.preventDefault();
}
});
Here you go Below is the updated script of your fiddle :
$('.send').click(function(e) {
var a = $('.dupa').val();
if(a == "1")
{
alert('Dupa');
e.preventDefault();
}
});
Also check this : http://jsfiddle.net/QgZHC/6/
لا تنتمي إلى StackOverflow