Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
Line 4: | Line 4: | ||
var list_items = document.getElementsByTagName("li"); | var list_items = document.getElementsByTagName("li"); | ||
− | + | for (var i = 0; i < list_items.length; ++i) { | |
− | + | var list_item = list_items[i]; | |
− | + | console.log(list_item); | |
− | + | var show = list_item.getAttribute("show"); | |
− | + | if (show != []._) { | |
− | + | var elementToShow = document.getElementById(show); | |
− | + | console.log("elementToShow: " + elementToShow ); | |
− | + | if (elementToShow != []._) { | |
− | + | list_item.onclick = function() { | |
− | + | elementToShow.display = 'block'; | |
− | |||
} | } | ||
+ | elementToShow.display = 'none'; | ||
} | } | ||
} | } | ||
− | + | } | |
− |
Revision as of 15:53, 2 March 2016
/* Any JavaScript here will be loaded for all users on every page load. */
var list_items = document.getElementsByTagName("li");
for (var i = 0; i < list_items.length; ++i) {
var list_item = list_items[i];
console.log(list_item);
var show = list_item.getAttribute("show");
if (show != []._) {
var elementToShow = document.getElementById(show);
console.log("elementToShow: " + elementToShow );
if (elementToShow != []._) {
list_item.onclick = function() {
elementToShow.display = 'block';
}
elementToShow.display = 'none';
}
}
}