JavaScript - prompt()中的多行文本框? [英] JavaScript - multi-line textbox in prompt()?

查看:2129
本文介绍了JavaScript - prompt()中的多行文本框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论如何要在提示符 c>多行中创建文本框/输入框?

Is there anyway to make the textbox/input box in prompt multiline?

推荐答案

不,浏览器只允许 prompt()的单行输入。但是,只需对 jQuery Alert Dialogs 库进行简单的更改即可可以在那里得到多行输入。拿 jquery.alerts.js ,查找< input type =textsize =30id =popup_prompt/> 并将其替换为< textarea rows =5cols =30id =popup_prompt>< / textarea> 。这应该是在调用 jPrompt()时显示一个多行输入字段。

No, browsers only allow single-line input for prompt(). However, with a simple change to the jQuery Alert Dialogs library you could get multi-line input there. Take jquery.alerts.js, look for <input type="text" size="30" id="popup_prompt" /> and replace it by <textarea rows="5" cols="30" id="popup_prompt"></textarea>. That should do to have a multi-line input field show up when calling jPrompt().

编辑:正如Mulletfingers999在评论中指出的那样,jQuery Alert Dialogs已被弃用,转而支持 jQuery UI对话框。在那里你也可以显示一个模态对话框,该对话框可以有任意内容 - 这意味着如果你想要多行输入,可以使用< textarea> 标签。

Edit: As Mulletfingers999 points out in a comment, jQuery Alert Dialogs have been deprecated in favor of jQuery UI dialogs. There you can also show a "modal" dialog, that dialog can have arbitrary content however - meaning that a <textarea> tag is possible if you want multi-line input.

这篇关于JavaScript - prompt()中的多行文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆