Set dropdown Selected text using jquery

This is a method that works based on the text of the option, not the index. Just tested.
 
var theText = "GOOGLE";
$("#HowYouKnow option:contains(" + theText + ")").attr('selected', 'selected');

Or, if there are similar values :
 
$("#HowYouKnow option").each(function() {
  if($(this).text() == theText) {
    $(this).attr('selected', 'selected');            
  }                        
});

Comments

Popular posts from this blog

what is Event Cache table in sharepoint

CAML Query syntax and options in SharePoint

Change anchor link url in sharepoint calender