我有類似在javascript中執行字符串變量的內容作爲代碼行嗎?
「_onmouseover」: 「this.className = this.className.replace( '懸停', '')」;
我試圖像
buttonObject.onmouseover =函數(){ 窗口[this.someObject._ _onmouseover]()執行它; };
而且我不知道它有多可能。
讓我告訴你們我的情景。我正在創建這個插件,在jquery對話框中生成四種類型的對話消息。那些是'警告','錯誤','注意'和'確認'。因此,讓我們說在dom中有4個跨度應該觸發這四個。
<span id='DialogueWarning'> Warning </span>
<span id='DialogueError'> Error </span>
<span id='DialogueNote'> Note </span>
<span id='DialogueConfirm'> Confirm </span>
現在讓hadle點擊表示對話
jQuery('#DialogueWarning').click(function(){
var dialogue = new Dialogue({
"type":"Warning",
"message":"Are you sure you want to close this window without saving your changes?",
"buttons":
[
{
"text":"Close without saving",
"_onmouseover": "this.className+=' hover'",
"_onmouseout":"this.className=this.className.replace(' hover', '')",
"bClass":"e_customButton"
},
{
"text":"Don't Close",
"_onmouseover": "this.className+=' hover'",
"_onmouseout":"this.className=this.className.replace(' hover', '')",
"bClass":"e_customButton"
}
],
"closeOnBackgroundClick" : true
});
});
參見 「_onmouseover」 和_onmouseout啄,我需要這些。有什麼辦法可以通過其他方式
你可以在對話中顯示按鈕的處理嗎? – Anoop