文本 + randomchar 不起作用 [JavaScript]
<script>
function makeid()
{
var text = "var text = document.write(lastNumber);";
var possible = "*+-/";
for( var i=0; i < 1; i++ )
document.write(lastNumber + possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
document.write(makeid(1))</script>
我如何输入例如:23* 45- 13/等等。 怎么了? 它只显示 2 个数字,后面没有字符。
<script>
function makeid()
{
var text = "var text = document.write(lastNumber);";
var possible = "*+-/";
for( var i=0; i < 1; i++ )
document.write(lastNumber + possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
document.write(makeid(1))</script>
How do i make this to type for ex: 23* 45- 13/ and so on.
What is wrong?
It just show me 2 numbers and no char after.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
代码存在一些问题:
document.write
的返回值,尽管它不返回任何内容。另外:
只需让函数返回字符串而不是返回代码:
There are some problems with the code:
document.write
although it doesn't return anything.Also:
Just make the function return the string instead of returning code:
这有效,但我得到“88undefined+”,什么是未定义的,我该如何删除它?
that worked but i get "88undefined+ " what is undefinded and how do i delete it?