开发者

JQuery hover addclass not working

I am trying to use JQuery to change a picture inside of a nested li with an id of "logotest"

The classes I want applied are logotest1 and logotest2. Basically when the user hovers over the button, the picture is changed to a different one so the colors match. Here's a fiddle. Obviously the pictures aren't there, but maybe I am doing something wrong.

http://jsfiddle.net/b9XHe/

I don't have the classes logotest1 and 2 in the fiddle - can i开发者_如何学JAVAt not dynamically changed the background image of the li?


It's working because there is a :hover in the css that kicks in, and you should read up on correct css syntax.

Here is an example of changing classes with backgrounds : http://jsfiddle.net/b9XHe/28/

Another way to do it in jQuery is directly thru the .css() function, something like this:

$("#logotest").css("background", "url(/images/newBG.jpg)");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜