I have a series of labels
in my view JSP
. Each label
shows a unit of measure and if you want to edit it, it is replaced via javascript with a input
via button.
NOTE: both the labels and the input are elements with class="CCC_UNIDAD" to iterate later. The% co_of resulting simplified% would be something like this:
<label class="CCC_UNIDAD">%</label>
<input class="CCC_UNIDAD">
<input class="CCC_UNIDAD" value="$">
<label class="CCC_UNIDAD">€</label>
$.each($(".CCC_UNIDAD"), function (index, value) {
var valor = value.textContent === undefined
? (value.value === undefined ? "" : value.value)
: value.textContent;
alert("VALOR = " + valor);
});
As you can see, in the snippet, I try to take the value of the label ( html
), if I do not have it I look for the value of the input value.textContent
but it is not working correctly.
How can I differentiate which type of element is the variable value.value
to get the attribute corresponding to each type?