Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
143
rated 0 times [  144] [ 1]  / answers: 1 / hits: 18794  / 12 Years ago, tue, july 10, 2012, 12:00:00

I have many divs in an html page. I need to give these divs a drop shadow effect on mouseover using jQuery/Javascript. I can get it work if the drop shadow is to be applied initially but I am not able to get it work at the run time.



The divs which needs to have shadow applied has a common class. In the fiddle it is test.



I have created a fiddle



http://jsfiddle.net/bobbyfrancisjoseph/ZEuVE/2/



It should work on IE8 and above and so I guess CSS3 can be used.


More From » jquery

 Answers
9

use this css for the shadow effect (covers most browsers):



.classWithShadow{
-moz-box-shadow: 3px 3px 4px #000;
-webkit-box-shadow: 3px 3px 4px #000;
box-shadow: 3px 3px 4px #000;
}


use the following jquery:



$(.yourDiv).hover(function()
{
$(this).toggleClass('classWithShadow');
});


Complete code here: http://jsfiddle.net/ZEuVE/3/



EDIT: sorry , I editted your initial fiddle instead of making a new one. But it works ^^ :)


[#84358] Monday, July 9, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hallie

Total Points: 503
Total Questions: 114
Total Answers: 103

Location: Iraq
Member since Fri, Jun 5, 2020
4 Years ago
;