i want to find selectbox option value and make that value = first index(value) with JQuery

Viewed 79

I cant find and edit selectBox option like input how can i do that? I want to find selectbox and make that value = first option. It's my code and it seems right but doesnt working what am i missing? Thanks for Helping.

   $('.clear-form').click(function () {

    $(this).parents('form').find('select').each(function (i, v) {
        $('select[name="' + $(v).attr('name') + '"] option').eq(0).prop("selected",true);
    });


});
1 Answers

try this one

 $('.clear-form').click(function () {

    $(this).parents('form').find('select').each(function (i, v) {
        $(this).prop("selectedIndex",-1);
    });

});
Related