0

Can you please let me know how to reset Dropdown value to empty using jQuery.

I tried using like this on Dropdown doen changed event but it is not working. Can you please help me. Below is the code i tried

$("select[title='"+Hide_Column+"']option:first-child").attr("selected", "selected");


$(document).ready(function(){
CheckDropdown("Drop1","Drop2");
CheckDropdown("Drop2","Drop3");
}); 
DropDownColum.change(function() {
var DropDownColum=$("select[title='"+Drop_Column+"']");
var value = $(this).val();// Value of selected option
        var Text = $(this).val();// Text of selected option
       // alert('Value: '+value);
       // alert('Text:' +Text);
if (Text == "")
{
$("select[title='"+Hide_Column+"']option:first-child").attr("selected", "selected");    
HideColumn(Hide_Column,"True");
} 
else
{
HideColumn(Hide_Column,"False");
}
});
function HideColumn(Column,IsHide)
{    
     if(IsHide=="True")
     {  
        $('nobr:contains("'+Column+'")').closest('tr').hide();
     }
     else
     { 
        $('nobr:contains("'+Column+'")').closest('tr').show();


 }
 }
1

This will work only if the drop-down control has an option with empty value.

Try below

$("select[title='"+Hide_Column+"']").val('');

Another option is to select the first option as below

$("select[title='"+Hide_Column+"']").find('option:eq(0)').prop('selected', true); 
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.