I'm not sure if this is possible, but basically I am making a live preview of html and css entered into textarea's and displaying it inside a div (#previewStyle). I am showing this via javascript/jquery using .keyup
$(function(){
$(".updatepreview").keyup(function(){
$.post( "<?php echo http() . $websitedomain .'/.../.../styles.php'; ?>", $("#styles_form").serialize(), function(result_data){ $("#previewStyle").html(result_data); /* use result data here */ } );
});
Here is the problem: When it loads the css, it updates everything on page (even outside of the div). Is there any way to limit this using jquery to JUST the div? I can go in and change all my id's and classes for everything outside of the div if necessary to make sure there is no conflict; however, wanted to check on here for a solution first. One textarea contains css, one contains html and it serializes them and loads them via the following:
<?php echo "
<html>
<head>
<style> ".$_POST['style']."</style>
</head>
<body>".$_POST['html']."</body>
</html>";
?>
Update:
The preview div does display correctly; however, the css inside preview div updates and overrides css outside of preview div. I'm trying to determine if there is a way to limit the css inside preview div to ONLY the preview div and not have it override my main stylesheet for the page around the preview div.