Monday 17 October 2011

Get the current value of the first element in the set of matched elements in jquery


Hi in this article i explain about how to get the current value of the first element in the set of matched elements in jquery


$('select.foo option:selected').val();
    // get the value from a dropdown select

$('select.foo').val();                    // get the value from a dropdown select even easier

$('input:checkbox:checked').val();        // get the value from a checked checkbox

$('input:radio[name=bar]:checked').val(); // get the value from a set of radio buttons