html看起来像这样:
<ul id="nav">
<li>
<a class="parent">First Level<img class="right" src="gfx/arrow-news-slider-title.png"></a>
<ul class="light">
<li class="full">
<a href="">Second Level</a>
</li>
<li class="full">
<a href="">Third Level</a>
</li>
<li class="full">
<a href="">...</a>
</li>
</ul>
</li>
到目前为止,这是脚本:
window['DropDown'] = {
open: function(e){
var dd = this;
var a = $(e).children('a:first-child');
$(e).children('ul').slideDown();
$(a).unbind('click');
$(a).bind('click',function(){dd.close(e)});
$(e).addClass('open');
},
close:function(e){
var dd = this;
var a = $(e).children('a:first-child');
$(e).children('ul').slideUp();
$(a).unbind('click');
$(a).bind('click',function(){dd.open(e)});
$(e).removeClass('open');
},
init:function(){
var dd = this;
$('#nav').find('li').each(function(){
if($(this).find('ul').length > 0){
var li = this;
var $li = $(this);
var a = $li.children('a:first-child')
$(a).bind('click',function(){
dd.open(li);
});
}
});
}
};
目前,您可以通过点击li标签中的任意位置打开所有“First Level”,但我只想在单击箭头图像时打开它们。有没有人有一个想法如何做到这一点?
答案 0 :(得分:1)
<script>
$(document).ready(function(){
$("a#YourLink img").event();
});
</script>