-3
A
回答
0
的Javascript
function yourfunction()
{
// code
return result;
}
HTML
<button onclick="alert(yourfunction());">Click</button>
DEMO
function myfunction()
{
return "It works";
}
<button onclick="alert(myfunction())">Clic</button>
0
您可以嘗試使用jQuery UI的對話框:
function someFunction() {
return 42;
}
$(function() {
$('<div>' + someFunction() + '</div>').appendTo('body').dialog();
});
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
-1
像這樣:
HTML
<button id="button">
Show results
</button>
JS
// The function whose results we want to print out
function foo() {
var result = "bar";
// we need to return the result
return result;
}
// get the button in the HTML
var button = document.getElementById("button");
// attach the click event on it
button.addEventListener("click", function() {
// after clicking the button, show the results
alert(foo());
});
相關問題
- 1. 如何在顯示對話框時調用JavaScript函數?
- 2. 按鈕jQuery的對話框不顯示
- 3. 如何在單擊按鈕時在結果中顯示結果?
- 4. 顯示在YUI使用JavaScript對話框
- 5. 對話框顯示相同的結果
- 6. 如何在jQuery對話框中顯示PHP結果
- 7. jquery ui對話框按鈕隱藏和顯示,如果id isset
- 8. 如何在點擊按鈕時顯示我的Facebook對話框?
- 9. JQuery對話框不顯示按鈕
- 10. 對話框不顯示正負按鈕
- 11. 警告對話框顯示按鈕
- 12. 解析數據並使用對話框/吐司顯示結果
- 13. 如何使用jquery在對話框按鈕中顯示打印圖標?
- 14. jQuery UI對話框顯示MySQL結果
- 15. 3個結果顯示對話框?
- 16. 如何禁用基於javascript函數的結果的按鈕
- 17. PhoneGap-iOS,如何用紅色按鈕顯示對話框?
- 18. 如何用ok按鈕顯示jquery對話框?
- 19. 如何在按鈕上單擊顯示自定義對話框
- 20. 如何在asp上顯示Jquery對話框:按鈕單擊
- 21. 如何在單選按鈕下方顯示JQuery-UI對話框
- 22. 如何在腳本運行後顯示jQueryUI對話框按鈕
- 23. 如何使用changePage函數顯示對話框?
- 24. 在下載對話框顯示時調用javascript函數
- 25. 使用ASP.NET按鈕顯示的jQuery UI對話框
- 26. 使用Javascript顯示對話框
- 27. 如何在Android中顯示對話框中的對話框?
- 28. 如何使用winforms將按鈕綁定到OK對話框的結果
- 29. 如何在javascript中使用對話框形式的jquery列表中的按鈕
- 30. 在Magnolia對話框中沒有顯示保存/取消對話框按鈕