I'm learning JS, and a little confused)
I'm trying to select all elements in page by className, find in them input that have type=hidden
, and take value of inputs to variable.
To be more clear I'll show demo html.
<div class="demo_class">
<p>lorem ipsum</p>
<input type="hidden" value="some-value">
</div>
<div class="demo_class">
<p>lorem ipsum</p>
<input type="hidden" value="some-value">
</div>
<div class="demo_class">
<p>lorem ipsum</p>
<input type="hidden" value="some-value">
</div>
<div class="demo_class">
<p>lorem ipsum</p>
<input type="hidden" value="some-value">
</div>
And there is some JavaScript
var container = document.getElementsByClassName("demo_class");
for (var i = 0; i < container.length; i++) {
var inputValue = container[i].querySelectorAll("input[type=hidden]");
container[i].insertAdjacentHTML(
'afterbegin',
'<a href ="' + inputValue + '">Some text</a>'
);
}
in this code I find all demo_class
, in each of them find input[type=hidden]
, but I cant do nothing with there value.. with code
inputValue.value
there is undefined. Why? What I doing wrong?
I no need jQuery, want to learn JavaScript.