[英]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.