简体   繁体   中英

jQuery event on element when mouseover on other element

Basically, I got a bunch of pictures and a table with names. When someone hovers the mouse over a picture, I want the name of that picture (name in the table) to light up, glow, whatever. My problem is I don't know how to trigger an event for an element when a different event is focused/'mouseovered'.

Please do help? (JS or jquery, either works)

Not exectly what you asked, it does not triggers events. However this is possible solution if you need to highlight some corresponding title for the image. Whatever, see this example http://jsfiddle.net/qYsu9/

$('ul img').hover(function() {
  var index = $(this).data('title');
  $('table .title').removeClass('active').filter('.title-' + index).addClass('active');
});

So you just add an active class to a corresponding title.

Maybe $('#caption').trigger('mouseovere'); is what you need.

Read more: http://api.jquery.com/trigger/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM