Javascript Function Gets Any Elements (input, select) Value
Get The Value Of Any Input Element Capable Of Having A Value Ie If Select Element The Text Of The Selectedindex If Input Element The .value
Home
Short:
/* ----------------------------------------------- Get the value of any input element capable of having a value ie if select element the text of the selectedIndex if input element the .value ---------------------------------------------- */ function elemValue(event) { let text = "", el = event.target, tagname = el.tagName.toLowerCase(); if (tagname === "select") { text = el.options[el.selectedIndex].text; } else if (tagname === "input") { text = el.value; } return text; }
source code home