Frage

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.

War es hilfreich?

Lösung

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top