html - tag next to a label in javascript -


i not have luxury of using jquery, want hide span tag in conditions using javascript , span tag not have id.

"<label name="lcity" id="lcity" for="city" class="formlabel" title="city">city:</label> <span class=spanclass>*</span> 

i tried , did not work:

var countyfieldlabel = document.getelementbyid('lcity').nextelementsibling; countyfieldlabel.visibility="hidden"; 

can suggest please?

thanks

you go right:-

visibility not element attribute instead style attribute.

use

 countyfieldlabel.style.visibility="hidden"; 

instead of

countyfieldlabel.visibility="hidden"; 

fiddle


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -