2012-12-05 58 views
0

我試圖用Twitter Bootstrap編寫AJAX類型的表單,但更新的div元素消失。我能解決這個問題嗎?在Twitter中更新div元素引導

<!DOCTYPE html> 
<html> 
    <head><link href="bootstrap.min.css" rel="stylesheet" media="screen"></head> 
    <script> 
    function wordCloud(){document.getElementById("cloud").innerHTML = "WordCloud";} 
    </script> 
    <body> 
    <script src="http://code.jquery.com/jquery-latest.js"></script> 
    <script src="bootstrap.min.js"></script> 
    <div id="cloud"></div> 
    <form onsubmit="wordCloud()"> 
    <fieldset> 
    <button type="submit" class="btn">Submit</button> 
    </fieldset> 
    </form></body> 
</html> 
+0

我懷疑你是不是防止默認的形式操作,以便一個提交頁面會重新加載 –

回答

1

變化如下。

function wordCloud(){document.getElementById("cloud").innerHTML = "WordCloud";} 

更換

function wordCloud(){document.getElementById("cloud").innerHTML = "WordCloud"; return false; } 

<form onsubmit="wordCloud()"> 

更換

<form onsubmit="return wordCloud()"> 
相關問題