wait on button click

T

tshad

Is there an easy way to wait on a button click?

I want to be able to show a div and then when the user presses the mouse
button, to then hide the div.

I can make it happen with a setTimeout to wait for 10-15 seconds, but I
would like to show it until the user presses the mouse.

Thanks,

Tom
 
U

Ugo

Is there an easy way to wait on a button click?
I want to be able to show a div and then when the user presses the mouse
button, to then hide the div.
I can make it happen with a setTimeout to wait for 10-15 seconds, but I
would like to show it until the user presses the mouse.

maybe, it's sufficient to use event handler "onclick", so:

<div id="layer"></div>
<input type="button"
value="hide"
onclick="document.getElementById('layer').style.visibility='hidden';"
/>
 
S

SAM

tshad a écrit :
Is there an easy way to wait on a button click?

I want to be able to show a div and then when the user presses the mouse
button, to then hide the div.

I can make it happen with a setTimeout to wait for 10-15 seconds, but I
would like to show it until the user presses the mouse.

<html>
<script type="text/javascript">
function hidSho(id) {
var d = document.getElementById(id).style;
d.visibility = d.visibility==''? 'visible' : '';
}
function shoHid(id) {
var d = document.getElementById(id).style;
d.visibility = d.visibility==''? 'hidden' : '';
}
</script>
<style type="text/css">
#test { visibility: hidden; border: 1px solid }
</style>
<h2 id="test">here is the test 1</h2>
<p>pass mouse <a href="#"
onmouseover="hidSho('test');"
onmouseout="hidSho('test');"
onclick="return false;">over me</a></p>
<p><button onmousedown="hidSho('test');"
onmouseup="hidSho('test');">press me</button></p>

<h2 id="test2">here is the test 2</h2>
<p><button onmousedown="shoHid('test2');"
onmouseup="shoHid('test2');">press me</button></p>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top