I have multiple buttons and inputs. I am trying to push innerText to array. Since there are different types of tags I need to specify 'if' to pick either the value for inputs or innerText of buttons.
This is what I have so far:
if ($("#dragulaContainer2").children().length > 0) {
var arraySelected = [];
var children = $('#dragulaContainer2').children();
for (var i = 0; i < children.length; i++) {
arraySelected.push(children[i].innerText);
}
console.log(arraySelected);
}
My non-coding logic behind it would be:
If childrens inner Text equals "" than take value instead.
But how to build the code? And add it to innerText line as if statement?
Added this but it is not working....
if ($("#dragulaContainer2").children().length > 0) {
var arraySelected = [];
var children = $('#dragulaContainer2').children();
for (var i = 0; i < children.length; i++) {
arraySelected.push(children[i].(if (innerText === "") {
val
} else {
innerText
});
}
console.log(arraySelected);
}
forloop? Does it go inside?children[i].tagNameyou can reference.