Hello! Help people figure it out, there is a table, there are pictures in it, when hovering, you need to add a style with a frame, you need to do this using jQuery.

It seems everything turned out to be done, but the cant is that when you hover over one picture everything is highlighted, and you only need the one on which pointer, I see that the function was not correctly written, but I can’t figure out what to do to make it work correctly.

Help me please!

Here is the code

  • 3
    And why jQuery? Through css, this is one rule given by .link a: hover img {border: 2px red solid; padding: 5px} - Owlet
  • Same option, but jQuery is necessary, the frame was just an example. - Artyomich

3 answers 3

Overdone Enough of this code:

$(document).ready(function(){ $("img").mouseover(function() { $(this).css('border', '2px red solid'); }); $("img").mouseout(function() { $(this).css('border', '0px'); }); }); 

Of course, the events prescribed for links are no longer needed.

  • SPASIBOMS :) - Artyomich
  • In general, this crap is given by means of css. - Indifferent
  • Maaalenky nuance adds this effect to all the pictures, this does not help $ (". Link img") - Artyomich
  • look at my example - thunder

Could be so:

 $(function(){ $("img").hover(function() { $(this).css('border', '2px red solid'); }, function() { $(this).css('border', ''); }); }); 

http://jsfiddle.net/QeVtR/2/

  • one
    applies only to images inside the element with the class .link - thunder
  • Yes indeed! Thank! And please explain the code, if not difficult, two functions separated by a comma, did not come across, is there a resource where you can read? - Artyomich
  • of course there is) api jquery is called: api.jquery.com/hover ;) hover takes 2 functions at the fak: 1st, which is done when you hover the mouse. 2nd, which is performed when removing the mouse from the element. In general, read the jquery documentation, there are many examples of use. in javaskarpte, and even more so in jquery, it is very common, so get used :) - thunder
  • Well, the API is clear :), I use it regularly, I just meet the syntax for listing functions separated by commas for the first time :) Thanks for the help! - Artyomich
  • you are welcome. js allows such constructions, and this is convenient) - thunder