I am facing an issue when trying to dynamically apply CSS to a loaded div using the load()
function. The HTML content is being successfully loaded and inserted, and I can activate a close command. However, the CSS styles that I want to apply are not taking effect. Everything else seems to be working as expected except for the dynamic CSS. I suspect there might be something incorrect in my code or within the function I am using:
JQuery:
$(document).ready(function() {
//Find & Open
$(".projectThumb").click(function(){
htmlName = $(this).find("img").attr("name");
$("#popupContainer").load(htmlName + ".html");
});
//Apply CSS
$(".projectPopup").css({"position": "absolute", "background": "#000", "top": "10%", "left": "10px"});
//Close property
$("a.close").live("click", function(){
$("#popupContainer").empty();
});
});
test.php:
<div id="content">
<div class="projectThumb">
<img src="/img/aeffect_button_static.gif" name="aeffect" />
<p class="title">title</p>
</div>
</div>
<div id="popupContainer"></div>
aeffect.html:
<div class="projectPopup" id="aeffect">
<a class="close">Close ×</a>
<p class="description">Description</p>
</div>