简体   繁体   中英

window.prompt multiple line input JavaScript CSS

I am trying to find a way to make something equivalent to window.prompt , but which allows multiple lines of input.

I could create my own using a div with z-index containing a textArea , but I am hoping there is something out there in jQuery or a plugin that would be more elegant.

Any ideas?

You can use the jQuery Dialog to do that.

Here's an example: http://jsfiddle.net/RBKaZ/

Using this HTML

<div id="dialog">
    <p>Please enter your name</p>
    <textarea id="name"></textarea>
</div>
<label>Name entered: </label>
<label id="nameentered"></label>
<br />
<input type="button" id="open" value="Open Dialog" />

And this jQuery:

$("#dialog").dialog({
    autoOpen: false,
    buttons: { 
        Ok: function() {
            $("#nameentered").text($("#name").val());
            $(this).dialog("close");
        },
        Cancel: function () {
            $(this).dialog("close");
        }
    }
});

$("#open").click(function () {
    $("#dialog").dialog("open");
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM