the default state is:
<a href="./" class="dynamic dynamic-children menu-item"><span class="additional-background"><span class="menu-item-text">Présentation</span></span></a>
so if class = rfr-opened add alt="open"
<a alt="open" href="./" class="dynamic dynamic-children menu-item rfr-opened"><span class="additional-background"><span class="menu-item-开发者_运维问答text">Présentation</span></span></a>
so if class doesn't have rfr-opened add alt="close"
<a alt="closed" href="./" class="dynamic dynamic-children menu-item"><span class="additional-background"><span class="menu-item-text">Présentation</span></span></a>
Something like this?
$('a').attr('alt', 'closed');
$('a.rfr-opened').attr('alt', 'open');
Demonstration: http://jsfiddle.net/9xLYV/
Tried and tested: http://jsfiddle.net/eMagu/ (I used inspector to check the alt value)
jQuery one liner...
// set all menu items to closed, then filter just the open class and set to open
$('.menu-item').attr('alt','closed').filter('.rfr-opened').attr('alt','open')
This should help:
$('.menu-item').each(function () {
if ($(this).hasClass('rtf-opened')) $(this).attr('alt', 'open');
else $(this).attr('alt', 'closed');
});
I think something along the lines of . . .
$('a.menu-item')each(function() {
if($(this).hasClass('rfr-opened')) {
$(this).attr('alt', 'open');
} else {
$(this).attr('alt', 'closed');
}
});
this works for me
jQuery("#rfr-topnav a").click(function () {
$('#rfr-topnav a').attr('title', 'closed');
$('#rfr-topnav a.rfr-opened').attr('title', 'open');
});
精彩评论