[英]I am getting error running function in html
我有一個需要從html調用的函數。 但是,此刻我打電話的方式導致typeError。 有人可以告訴我如何運行此函數嗎:splitboxes(); 在我的html標記中。
如果我只運行“ splitboxes”,則該函數早先聲明並可以使用,但需要將其作為函數調用。
謝謝
$("html").append("<div id='dialog-success' />");
var dialogSuccess = $("#dialog-success");
dialogSuccess.html('<br />Here the details of your submitted intake ' +
'<br /><b><font color="green">' + depts + '</font></b><br />' + splitboxes(); +
' This entry was successfully submitted to the database.<br />Thank you.');
您有語法錯誤:
...+ splitboxes(); + ...
至
...+ splitboxes() + ...
請使用IDE進行編碼。 它可以使您免於頭痛:)
$("html").prepend("<div id='dialog-success' />"); var dialogSuccess = $("#dialog-success"); dialogSuccess.html('<br />Here the details of your submitted intake <br /><b><font color="green">depts</font></b><br />' + splitboxes()+' This entry was successfully submitted to the database.<br />Thank you.'); function splitboxes(){ return "<i>output from splitboxes() function</i>"; }
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> </head> <body> </body> </html>
只是移開;
來自+ splitboxes(); +
+ splitboxes(); +
這是代碼和輸出
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.