Reputation: 9855
im trying to move the background position of an element when a certain div is clicked only I cant seem to get it working.
My jquery seems fine from the documentation?
$(this).children('ul li').css('background-position-x','100px');
Heres a jsfiddle demo... http://jsfiddle.net/shqcu/
Upvotes: 1
Views: 2055
Reputation: 2967
$(this).css('background-image','url(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQBFaoYPOnLv_EI4sGOisRrHUGhlHjJp7iY2A4RT1PKXAAPxx3f)');
Upvotes: 0
Reputation: 599
You can't alter an element's background-position with jQuery alone. You need this plugin http://keith-wood.name/backgroundPos.html
Upvotes: 0
Reputation: 145458
Use find()
instead of children()
:
$(this).find("ul li").css("background-position-x", "100px");
DEMO: http://jsfiddle.net/shqcu/1/
Upvotes: 7