Js set the control of the hidden and display two methods

  • 2020-03-30 03:44:34
  • OfStack

There are two ways to hide a control in JavaScript, by setting the "display" and "visibility" properties of the control's style.

When style.display="block" or style.visibility="visible", when style.display="none" or style.visibility="hidden", the control is not visible. The difference is that "display" not only hides the control, but the hidden control no longer occupies the position occupied by the display, while "visibility" hides the control only by making the control invisible, and the control still occupies its original position.


function displayHideUI()
{
var ui =document.getElementById("bbs");
ui.style.display="none";
}
function displayShowUI()
{
var ui =document.getElementById("bbs");
ui.style.display="";//Display will work fine if it's empty, and a block will wrap the space behind it
}
function visibilityHideUI()
{
var ui =document.getElementById("bbs");
ui.style.visibility="hidden";
}
function visibilityShowUI()
{
var ui =document.getElementById("bbs");
ui.style.visibility="visible";
}
</script>

The problem solved today is to give an id to the class.error of the CSS definition in the JSP page, and then to clear the js prompt when the div is collapsed by controlling the visibility of the id. The details are as follows:
Var label1 = document.getelementbyid ("label1") in the prepared interface function;


$(document).ready(function() {
$(".flipp .span4").click(function() {
$(this).parent().next().toggle();
$(this).parent().parent().prevAll().find(".panel").hide();
$(this).parent().parent().nextAll().find(".panel").hide();
var label1 = document.getElementById("label1");
label1.style.display="none";
})

Then add the corresponding place in the JSP:


<label class="error" id="label1" for="currentPWD" generated="true" style="display:inline"></label>

For the label.error class defined by CSS, you can use $("label.error").removeattr ("style").attr("style", "display: none;" ); To implement the above functions. Also, it seems that you don't need to define an id value for the label at the corresponding location underground.


Related articles: