Quite new to jQuery so exercise patience with me :)
I think this should be a quick one: On clicking .color, I've appended some basic HTML to a page with the class .selected. When I hover on any div.color with the html (.selected) appended inside of it, I want to add some CSS to .selected to give it a hover on state, by using
$('.color').toggle(
function(){
$('.color').empty('span'),
$(this).append("<span class='selected'></span>")
},
function() {
$('.color').empty('span');
})
$('.color').click( function(){
$('.color').toggle;
})
$('.color').has('.selected').hover(
function(){
$(".color span").css('background-position', '0px -24px');
},
function() {
$(".color span").css('background-position', '0px 0px');
})
The problem is that jQuery isn't recognizing that the appended html exists. I've manually inserted the HTML and it works perfectly, but through .append it doesn't cooperate.
Thanks
EDIT: Demo here: http://judsoncollier.com/DEMO/
:hoverpseudo class in your CSS rather than using javascript? And for your javascript, is there any reason why you're adding a span rather than just adding a class to the existing object?