0
我想將jquery themeroller highlight/error html應用於我的jQuery代碼。這是jQuery的亮點代碼是這樣(錯誤代碼是相似的):將CSS應用於jQuery代碼
<div class="ui-widget">
<div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
<strong>Hey!</strong> Sample ui-state-highlight style.</p>
</div>
</div>
我已經構建這樣我的代碼:
function doAjax(){
$.ajax({
url: 'myfile.php',
success: function(data) {
if (data == 'Initializing...please wait')
{
$('#quote p').html(data); //here I would add highlight css code
setTimeout(doAjax, 2000);
}
else
{
$('#quote p').html(data); //here is error css code
}
}
});
}
這打印到一個div:
<div id="quote"><p> </p></div>
使用.css()
這裏很麻煩,我想。有沒有辦法將HTML添加到條件?請注意,.html(data)
是必要的,因爲您從服務器獲得不同的消息,除非有其他建議。
令人驚歎的是,感謝所有的努力。這比我想象的更復雜。 – Tom