Difference between revisions of "MediaWiki:Common.js"
Line 7: | Line 7: | ||
− | $(function () { | + | $(function myFunction() { |
− | |||
var newInput = document.createElement("INPUT"); | var newInput = document.createElement("INPUT"); | ||
+ | newInput.id = 'dropdown'; | ||
newInput.setAttribute("list", "viscosity"); | newInput.setAttribute("list", "viscosity"); | ||
− | document.getElementById(" | + | document.getElementById("dropdown").appendChild(newInput); |
var newDataList = document.createElement("DATALIST"); | var newDataList = document.createElement("DATALIST"); | ||
newDataList.setAttribute("id", "viscosity"); | newDataList.setAttribute("id", "viscosity"); | ||
− | document.getElementById(" | + | document.getElementById("dropdown").appendChild(newDataList); |
var newViscosity = function (viscosity) { | var newViscosity = function (viscosity) { | ||
Line 22: | Line 22: | ||
document.getElementById("viscosity").appendChild(newOption); | document.getElementById("viscosity").appendChild(newOption); | ||
}; | }; | ||
− | + | ||
newViscosity(10); | newViscosity(10); | ||
newViscosity(100); | newViscosity(100); | ||
newViscosity(1000); | newViscosity(1000); | ||
}()); | }()); |
Revision as of 21:38, 19 February 2019
/* Any JavaScript here will be loaded for all users on every page load. */ $(function () { var myElement = document.getElementById('displayText'); myElement.innerHTML = 'any HTML'; }()); $(function myFunction() { var newInput = document.createElement("INPUT"); newInput.id = 'dropdown'; newInput.setAttribute("list", "viscosity"); document.getElementById("dropdown").appendChild(newInput); var newDataList = document.createElement("DATALIST"); newDataList.setAttribute("id", "viscosity"); document.getElementById("dropdown").appendChild(newDataList); var newViscosity = function (viscosity) { var newOption = document.createElement("OPTION"); newOption.setAttribute("value", viscosity); document.getElementById("viscosity").appendChild(newOption); }; newViscosity(10); newViscosity(100); newViscosity(1000); }());