html - Set selected option in dropdown using jQuery not working on IE -



html - Set selected option in dropdown using jQuery not working on IE -

i have 2 dropdown lists created dynamically , i'm trying set default "selected" alternative using jquery. works in chrome, can't work in ie9.

this i've tried far: js

$("#dropdown").append($('<option>', { value: 'all', text: 'all' })).prepend($('<option>', { value: 'select financial year', text: 'select financial year', select: 'selected' })); $("#dropdownro").prepend($('<option>', { value: 'select ro', text: 'select ro' })).attr("selected", true).append($('<option>', { value: 'all', text: 'all' }));

as can see tried different ways each dropdown see 1 worked. tried utilize .attr("selected", "selected"), same. there i'm missing create simple thing work in ie? thanks!

in first block, you're setting select attribute, when should selected.

$("#dropdown").append($('<option>', { value: 'all', text: 'all' })).prepend($('<option>', { value: 'select financial year', text: 'select financial year', selected: 'selected' }));

in sec block, you're applying .attr() $("#dropdownro"), not <option> you're adding (check parentheses). should be:

$("#dropdownro").prepend($('<option>', { value: 'select ro', text: 'select ro' }).attr("selected", true)).append($('<option>', { value: 'all', text: 'all' }));

i suggest both of them consistently. i'm showing 2 different ways write this.

jquery html

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -