Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show/Hide div, with plain JS

My CSS:

#a_x200{
    visibility: hidden;
    width: 200px;
    height: 200px;
    background-color: black;
}

My JS:

<script type="text/javascript">
    function show(id) {
        document.getElementById(id).style.display = 'block';
    }
</script>

My Html

<div id="a_x200">asd</div>
<innput type="button" class="button_p_1" onclick="show('a_x200');"></input>

Not working I think I missed something!

like image 369
Froxz Avatar asked Nov 30 '22 04:11

Froxz


2 Answers

try this:

document.getElementById('a_x200').style.visibility = 'visible';
like image 167
Artem Veikus Avatar answered Dec 04 '22 11:12

Artem Veikus


You can try this code:

HTML Code:
        <div id="a_x200" style="display:none;">asd</div>
        <input type="button" class="button_p_1" onclick="showStuff('a_x200');"></input>

Java script:

<script type="text/javascript">
function showStuff(id) {
        document.getElementById(id).style.display = "block";
}
</script>

Try this code it will solve your problem.

like image 36
simbu94 Avatar answered Dec 04 '22 11:12

simbu94