I have an element being created dynamically by jquery fonticonpicker. I am attempting to manipulate the icon, yet simply using the code below does not work. .icons-selector i is created by the plugin, dynamically.
I have always been successful at manipulating an element by merely writing my selector starting with an element that already existed i.e.: body or document. Can someone shed some light and alternate options to solve this problem please?
The goal is that I NEED the element to be modified after being loaded. No user action is required.
$(document).ready(function(){
iconContainerID = "id_12";
$('body #' + iconContainerID).css('background', 'red'); // this works!
$('body #' + iconContainerID + ' .icons-selector i').css('background', 'yellow'); // this doesnt work
});
Only when I have created another element on the page and added a click event to it, then clicked it.. does it finally style the
This works:
<a href="" id="clickme">click me</a>
$(document).on('click', '#clickme', function(){
iconContainerID = "id_12";
$('body #' + iconContainerID + ' .icons-selector i').css('background', 'yellow'); // this does work
});