I'm building a custom pulldown menu in jQuery. Now I'd like to set the text of the A.select element to the text of the element that is clicked. But I can't get it to work.
This is the html:
<div class="pulldown">
<a href="javascript:;" class="select">All cats/subs</a>
<div class="options">
<a href="javascript:;">Option one A</a>
<a href="javascript:;">Option two A</a>
<a href="javascript:;">Option three A</a>
<a href="javascript:;">Option four A</a>
</div>
</div>
This is the jQuery code:
$(document).ready(function() {
$('div.pulldown').toggle(function() {
$(this).css('z-index','110');
$('.options', this).css('z-index','100').show('fast');
$('.options A', this).click(function(){
var value = $(this).text();
$(this).closest('DIV.pulldown A.select').text(value);
});
}, function(){
$(this).css('z-index','10');
$('.options', this).css('z-index','0').hide('fast');
}); });
What am I missing here?