开发者

How to set :hover on a li(A) when hover an other li(B)

I am daily an iOS developer, but i'm trying to give a help for a friend in php and jquery, since I didn't do Jquery for a lonnng time, im asking you guys a little help :)

So let's say I got this, for a unique ID

< li class="listname" value="'.$id.'">

When I go hover this, I want to li:hover this for the same unique ID

< li class="listpicture" value="'.$id.'>

My CSS job is done, when I go hover one, it does the job.

I began my script with something like that

$("li.listname").mouseover( function() {
  var id = $("li.listpicture").attr('value');

// and miss some job he开发者_Python百科re
}

I feel a little bit noob on this, but I will feel free to help you with iOS Developement :)

Thx


Could make a new class for the hover effect and just assign it and remove it on hover. Im making the assumption that id is the id of the other element you want to show the hover effect on.

css

li:hover, .active {/*styles*/}

JS

$("li.listname").hover( function() {
  var id = $("li.listpicture").attr('value');
  $(id).addClass('active');
},function(){
    var id = $("li.listpicture").attr('value');
    $(id).removeClass('active');
});

Live Demo

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜