문제

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:

http://jsfiddle.net/QgZHC/4/

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.

도움이 되었습니까?

해결책

다른 팁

$('.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/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top