javascript - jquery code not working with internet explorer - select box option based on another select box -


i have jquery script used show/hide values depending on select box , although works in firefox , chrome, doesn't work in ie

var otherselectoption = $('#select1,#select2,#select3').find('option').filter(function(){   return $(this).attr('value') != ""; });  $('#selectlist').change(function(){    var selected = $(this).val();    otherselectoption.hide().filter(function(){      return $(this).attr('value').indexof(selected) > -1;    }).show();  }); 

link demo here: http://jsfiddle.net/8g13wc5g/

also, each time select "---filter---" option rest of bottom 3 select boxes reset default value blank full set of options.

you can not in ie. can rather disable/enable options instead of hide/show in case of ie. other solution add/remove options instead of show/hide. not feasible on enable/disable options solution.

second part of question can add prop('selected', true) set relevant options selected

var otherselectoption = $('#select1,#select2,#select3').find('option'); $('#selectlist').change(function(){   var selected = $(this).val();   otherselectoption.prop('disabled', true);   otherselectoption.filter(function(){     return ($(this).attr('value').indexof(selected) > -1 ||$(this).attr('value') == "")  }).prop({'disabled': false}); }).change(); 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -