Created
September 30, 2010 09:10
-
-
Save daffydowden/604267 to your computer and use it in GitHub Desktop.
selecting an option from a dropdown with jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//on drop down selection, select the element in the hidden input | |
$('.qa-filter-select ul a').live('click', function(){ | |
$('#category option[value=selected]').val('') | |
$('.qa-filter-select option').eq($(this).index('.qa-filter-select ul a')).val('selected','selected'); | |
$('.qa-filter-select .selected').html($(this).html()); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solution:
$('.qa-filter-select ul a').live('click', function(){
$('#category option')['selected'] = false;
$('.qa-filter-select option')[$(this).index('.qa-filter-select ul a')]['selected'] = true;
$('.qa-filter-select .selected').html($(this).html());
});
Seems like .attr('selected','selected') should do this, but it doesn't. This doesn't visibly manipulate the dom though.