SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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();


 }
 }
share|improve this question
up vote 1 down vote accepted

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); 
share|improve this answer
    
Thanks that did the trick Awsome :-) – sandy143 Jan 5 '15 at 6:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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