4
There is a function onClick Javascript for each "Show more". This function changes the visibility of the div to Visible to which the default is Hidden.
However simple it is, the code is too big. Is there any way to shorten or lessen this?
Example: just a "Show more" button and a div? Then each click on "Show more" shows a div, one below the other?
<!DOCTYPE html>
<html>
<head>
<style>
input{
margin-top: 5px;
}
input#abreBt{
margin-left: 100px;
}
input#bt1{
margin-left: 50px;
}
hr{
width: 300px;
float: left;
}
</style>
</head>
<body>
<input type="button" name="abreBt" id="abreBt" value="Mostrar mais" onClick="javascript: abreBts1();" />
<div name="divHidden" id="divHidden" style="visibility: hidden;">
<input type="button" name="bt1" id="bt1" value="+" />
<input type="button" name="bt2" id="bt2" value="-" />
<input type="button" name="bt3" id="bt3" value="Novo" style="width: 100px;" />
<input type="button" name="bt4" id="bt4" value="+" /><br><hr><br>
</div>
<input type="button" name="abreBt" id="abreBt" value="Mostrar mais" onClick="javascript: abreBts2();" />
<div name="divHidden" id="divHidden2" style="visibility: hidden;">
<input type="button" name="bt1" id="bt1" value="+" />
<input type="button" name="bt2" id="bt2" value="-" />
<input type="button" name="bt3" id="bt3" value="Novo" style="width: 100px;" />
<input type="button" name="bt4" id="bt4" value="+" /><br><hr><br>
</div>
<input type="button" name="abreBt" id="abreBt" value="Mostrar mais" onClick="javascript: abreBts3();" />
<div name="divHidden" id="divHidden3" style="visibility: hidden;">
<input type="button" name="bt1" id="bt1" value="+" />
<input type="button" name="bt2" id="bt2" value="-" />
<input type="button" name="bt3" id="bt3" value="Novo" style="width: 100px;" />
<input type="button" name="bt4" id="bt4" value="+" /><br><hr><br>
</div>
</body>
</html>
<script>
function abreBts1(){
document.getElementById('divHidden').style.visibility="visible";
}
function abreBts2(){
document.getElementById('divHidden2').style.visibility="visible";
}
function abreBts3(){
document.getElementById('divHidden3').style.visibility="visible";
}
</script>
Hello! Can you put in your question the code you are using to make your div? Read more here. I also suggest that you separate this question into 3 (create two other questions with your other questions) - it is better for you, who is asking, it is better for those who will answer, and it is better for the site.
– Daniel
I made the code and I forgot to put in the question...
– MrVanDaime
Cool! I don’t know if it’s clear yet what you intend to do (maybe ask questions) but it’s already much better! + 1
– Daniel