English 中文(简体)
你们如何用 j子在森林论坛中吸引一片人的可见度? (IE和Kingper)
原标题:How do you toggle the visibility of a div in FF with javascript? (IE and Chrome work fine)

因此,我试图利用java书来唤醒人们的觉醒,这是它所认为的:

document.all["layer1"].style.visibility= visible ;

以及

document.all["layer1"].style.visibility= hidden ;

What would the syntax look like for this if I m trying to do it in Firefox? If I know that, then I ll add in an if statement to check if the browser is firefox 以及 use the alternate code.

最佳回答

。 你们必须用另一种方法 gr。

querySelector

document.querySelector( div#layer1 ).style.visibility =  hidden ;    
document.querySelector( div#layer1 ).style.visibility =  visible ;

页: 1

getElemenyById

document.getElementById( layer1 ).style.visibility =  hidden ;
document.getElementById( layer1 ).style.visibility =  visible ;

两种主要方法。

问题回答

Don t use document.all[]. 它没有得到所有浏览者的支持,在很大程度上是IE4时代的演奏。 取用document.getElementById(>进入<div> sid Depende:

document.getElementById("layer1").style.visibility =  hidden ;
document.getElementById("layer1").style.visibility =  visible ;

You can use querySelectorAll, but you ll then need to loop through the elements.

document.querySelectorAll( .layer ).forEach((element) => {
  element.style.visibility= hidden ;
});

rel=“nofollow noreferer”>https://jsfiddle.net/Haxen2000/xo8k0eqp/6/

//class named layer1
document.querySelectorAll( .layer1 ).style.display= none ;
document.querySelectorAll( .layer1 ).style.display= block ;
//id named layer1
document.querySelector( #layer1 ).style.display= none ;
document.querySelector( #layer1 ).style.display= block ;




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签