Hey guys, I have the following code to show/hide a div on click, but I can't get it working. Does anyone see what's wrong with my code?
HTML:
JS:HTML Code:<div id="settings"> <a href="#">settings</a> <ul> <li><label for="filter-nsfw">Hide NSFW</label> <input type="checkbox" id="filter-nsfw" name="filter-nsfw"></li> </ul> </div>
CSS:Code:function toggle(el) { (el.style.display == 'block') ? el.style.display = 'none' : el.style.display = 'block'; } document.getElementById('settings').getElementsByTagName('a').onclick = function(){ var settingsList = this.getElementsByTagName('ul'); toggle(settingsList); };
Thanks!Code:#settings {display: none;}


Reply With Quote
Bookmarks