我想在#photo-desc li上添加活動類,當鼠標懸停在#photo-menu li上時。jQuery目標與鼠標上的類相同的編號
$('#photo-menu li').on('mouseenter mouseleave', function(){
var pClass = this.className;
var pId = ('#photo-desc li').id;
if (pClass == pId) {$('#photo-desc li').addClass('active');}
});
<ul id="photo-menu">
<li class="photo-1"><a href="">Photo 1</a></li>
<li class="photo-2"><a href="">Photo 2</a></li>
<li class="photo-3"><a href="">Photo 3</a></li>
<li class="photo-4"><a href="">Photo 4</a></li>
</ul>
<ul id="photo-desc">
<li id="photo-1">Photo 1</li>
<li id="photo-2">Photo 2</li>
<li id="photo-3">Photo 3</li>
<li id="photo-4">Photo 4</li>
</ul>
製作小提琴,告訴我們 – Innodel 2014-10-20 12:56:42
@ ask4tec有什麼不對,我的答案是不適合你的要求是什麼? – 2014-10-21 06:53:46