Kalashir Kalashir - 1 year ago 110
Javascript Question

On clicking on close button of page i want to clear all selectbox value

I have 3 selectbox on my page and onClick of close button I want to clear all the selectbox which are under the class


Below is my code to clear fields.

clearText: function() {
$('.popupBody input').val('');
$('.popupBody select').val('');

For clearing all select boxes inside
class, I am using below code.

$('.popupBody select').val('');

Answer Source

For clearing selection made in select2 select box you can try following approach:

$('.popupBody select').each(function(){
    //iterate over all the select boxes one by one
    $(this).select2("val", ""); //clearing the selection made
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download