In the following code, the confirm box shows before addClass has been rendered (i.e. Safari 6.0.5). Is it possible to make sure addClass() is rendered before showing confirm() box?
<style type="text/css">
.preview { background-color: #eee;width:100;height:100;color:red; }
.preview_s { border:3px solid blue;}
</style>
<script type="text/javascript">
function test(i)
{
$("#testdiv"+i).addClass('preview_s');
if (confirm('border not blue and checkmark not visible on some browsers until after choice is made'))
{
// Do confirmed thing here
} else {
// Abort
}
}
</script>
<form id="testform">
<div class="preview" id="testdiv1">test1</div>
<input type="checkbox" onclick="test(1);">
<div class="preview" id="testdiv2">test2</div>
<input type="checkbox" onclick="test(2);">
</form>