I am using a button to create a new div every time the button is clicked. Ultimately, I am going to need a unique ID for each one of these new divs, but for now I need to change the CSS for certain child elements. Instead of using pseudo-class expressions, is there a way, using jQuery, that I can assign a unique ID number, and use that ID to alter the CSS of the new divs that are created?
Here is my code:
$("button[type=email]").click(function(){
$("<ul />")
.html('<div id="friend"><b>Friend Name<b><a class="close closethis tooltip" data-tooltip="Remove persona"><i class="icon-remove"></i></a></div>')
.appendTo("#drag-area");
});
You don't need to create an ID in the first place ..
You can use the .eq() selector
to target a specific div
inside the ul..
$('#drag-area').find('ul').eq(2).find('div').addClass('yourClass');