2012-04-12 54 views
0

叫我需要從JavaScript調用一個SimpleModal對話框......SimpleModal(jQuery的)失去CSS格式時的Javascript

我指的是下載的「確認覆蓋」演示上http://www.ericmmartin.com/projects/simplemodal-demos/

如果我使用...

<input type='button' name='confirm' class='confirm' value='Demo'/> 

...一切工作正常。但如果我用...

<script type="text/javascript"> 
    $('#confirm').modal(); 
</script> 

...「確認」DIV的文本內容會顯示,但沒有任何CSS格式。

怎麼了?非常感謝您的幫助。

----------------------- edited ---------------------- --------

回答我的問題...謝謝你,喬,指着我在正確的方向...

原來的CSS包含這樣的定義...

#confirm {display:none;} 

#confirm-overlay {background-color:#eee; cursor:wait;} 

#confirm-container {height:140px; width:420px; ...} 

顯然,只有當第一種方法調用SimpleModal時,纔會使用#confirm-overlay和#confirm-container。

如果我把所有的格式爲#confirm它似乎做工精細機智的JavaScript:

#confirm {display:none; background-color:#eee; cursor:wait; height:140px; width:420px; ... } 

回答

0

嘗試

... 
$('#confirm').addClass('confirm').modal(); 
... 

或者只是在你的CSS添加

#confirm{[style];} 

所以您正在通過ID對元素進行樣式設置,而不是依賴要應用的類。或者,只需在HTML中應用該類。