Home >Web Front-end >JS Tutorial >JS How to change the hidden attribute of span tag_javascript skills
Test:
test.html
Code:
js/Menu.js Code: Copy code The code is as follows: //This is using the custom method hideElement() and shwoElement() Test results: function isChang(values) { if(values=="yxsh"){ hideElement("key"); showElement("yxsh"); }else{ hideElement("yxsh"); showElement("key"); } } //Custom method hideElement() function hideElement( id){ document.getElementById(id).style.display="none"; } //Custom method showElement() function showElement(id){ document. getElementById(id).style.display=""; } //This is to directly set whether to hide or not without a custom function function isChang1(values) { if(values= ="yxsh"){ document.getElementById("yxsh").style.display=""; document.getElementById("key").style.display="none"; }else { document.getElementById("yxsh").style.display="none"; document.getElementById("key").style.display=""; } } The default selection is: by department This is if we choose: not by department, that is, by: employee number or name, then, It will be hidden at this time: and. .. If we choose: by department, that is, by default Then the result is: .. . and Statement: The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn Previous article:JavaScript anonymous function and closure_javascript skillsNext article:JavaScript anonymous function and closure_javascript skills Related articlesSee more
|