2
I have a code that only works if it keeps one <div id="panel">
, but would not like it to appear on the screen. It has to keep this div, but let it invisible?
2
I have a code that only works if it keeps one <div id="panel">
, but would not like it to appear on the screen. It has to keep this div, but let it invisible?
2
Or in the CSS:
<div id="panel" style="visibility:hidden;"></div>
or
#panel { visibility:hidden; }
It just doesn’t make a lot of sense, or I didn’t get it right.
2
To make invisible/hide the div
you can do so:
$("#panel").hide() ou $("#panel").css("display", "none")
The problem is if you are doing some validation to check if the div
is visible:
$("#panel").is(":visible")
Then you will have to change the validation to check if the div
exists:
if($("#panel").length > 0)
//div existe
1
If you’re using jQuery.
$('#sua-div').css('visibility', 'hidden');
If you’re using Javascript.
document.getElementById('sua-div').style.visibility = 'hidden';
1
If you use style="display:none;"
your div will be there, but will not be visible. See below for an example.
function mostraDiv(id,div2)
{
var divstyle = new String();
divstyle = document.getElementById(id).style.display;
var divAux = new String();
divAux = document.getElementById(div2).style.display;
if (divAux=="block" || divAux == ""){
document.getElementById(div2).style.display = "none";
}
document.getElementById(id).style.display = "block";
return false;
}
<a href="#" onclick="displayDiv('teste','teste2')"> </a>
<a href="#" onclick="displayDiv('teste2','teste')"> </a>
<div id="teste">
teste
</div>
<div id="teste2" style="display:none;">
teste2
</div>
Source: That post
1
complemented above, if using Angularjs.
<div id="panel" ng-show="false">
Browser other questions tagged html div
You are not signed in. Login or sign up in order to post.
When you say "code that it only works if it keeps a
<div id="panel">
" I’m curious what the code is? I think it would be interesting to solve this at the source of what to hide.– Sergio