Jump to content

is it possible to hide a div on button click?


mikejs

Recommended Posts

Hi is it possible to use java to close a div on this button click

 

<a class="button" id="submitbutton" href="#"><span id="buttontext">Search</span> </a>

 

I did try using

onclick="changeme('notice', 'hide');"

notice being the name of the div

 

with

<script>

function changeme(notice, action) {
       if (action=="hide") {
            document.getElementById(notice).style.display = "none";
       } else {
            document.getElementById(notice).style.display = "block";
       }
}

</script>

 

in my header but it didn't work any suggestions :-)

It sure is.. but its not done with PHP.. Wrong forum..

 

<a href="javascript:checkit('id')">Toggle View</a>
<div id="id">Some pretty stuff in here</div>

thats your html

<script type="text/javascript">
function checkit(var) {
document.getElementById(var).style.display = (document.getElementById(var).style.display == 'none' ? 'block' : 'none');
}
</script>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.