开发者

How can I have a textarea popup when the user clicks a button?

开发者 https://www.devze.com 2023-04-12 16:41 出处:网络
I\'ve tried PopBox to have a textarea pop up, but the functionality of PopBox seems to be incompatible with the game system. (For example, I know for a fact that alert(); and prompt(); works in the ht

I've tried PopBox to have a textarea pop up, but the functionality of PopBox seems to be incompatible with the game system. (For example, I know for a fact that alert(); and prompt(); works in the html page testing, but does not happen at all in the actual game)

开发者_JAVA百科

Currently the game has this confirm box system implemented. Is there a way to add a textarea to this?

If not, is there any other Jquery/JS tricks/plugins that will allow a textarea box to pop up when a button is clicked?


I'm no expert but I think this is possible:

<div id="textAreaDiv" style="visibility:hidden;"><textarea></textarea></div>

<input type="button" onClick="showTextArea()">
<input type="button" onClick="hideTextArea()">

<script>
function showTextArea() {
document.getElementById('textAreaDiv').style.visibility="visible";
}

function hideTextArea() {
document.getElementById('textAreaDiv').style.visibility="hidden";
}
</script>

OR...

To toggle the DIV with one button, you could do this:

<script>
function showHideTextarea() {
if (document.getElementById('textAreaDiv').style.visibility="hidden")
{
document.getElementById('textAreaDiv').style.visibility="visible";
}
else
{
document.getElementById('textAreaDiv').style.visibility="hidden";
}
}
</script>

And this doesn't need the JQuery library to use.

Hope it helps...


check this plugin

jAlert

very easy and clean to use, you can do whatever you want.

its easy to change the input by a textarea

in jquery.alerts.js file, search for 'prompt' case, and change the input by textarea.

i made this for me and have been working so far.


You can have a on the page, which inserts a textarea box when the button is clicked, something like this...

In original HTML page, stick a blank area, maybe reserving space like so

<div id="Input_Area">
<br>
<br>
</div>

Then, put an onClick event on your button which replaces the innerHTML with your textarea (or create a function that does it, and call it with your onClick event).


you can try jquery dialog http://jqueryui.it/demos/dialog.

This pops open an overlay and a dialog. You can customize this display and interaction to your hearts desire.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号