Reputation: 1070
Im trying to get the value of my hidden field lengthIndicator
:
<div class="dwr_frame_wpr">
<div class="dwr_arrow_left L"></div>
<div class="dwr_frame L">
<div class="dwr_biggy">
<div class="dwr_box L"></div>
<div class="dwr_box L"></div>
<div class="dwr_box L"></div>
</div>
<div class="points_wpr">
</div>
<input type="hidden" class="lengthIndicator" value="0" />
<input type="hidden" class="whatNowIndicator" value="1" />
</div>
<div class="dwr_arrow_right L"></div>
</div>
Now, I have a JS code that basically count the length of lengthIndicator
, and write it in the hidden input type. (thats happening on "ready
").
after that, on "click
" , Im tryint to read the input , and its showing undefind on the console. Im trying to unserstand why ?
(this is the code : (im passing a "dwr_arrow_left" element on click.) )
checkHowManySliders: function (el) {
console.log(el);
var lengthInd = el.find('.lengthIndicator');
console.log(el.find('.lengthIndicator').val());
}
when Im console the element , it says its getting the element great, but when Im trying to watch the value its getting undefined.
Upvotes: 0
Views: 1797
Reputation: 3938
lengthIndicator
is not a child of the dwr_arrow_left
, because dwr_arrow_left
is empty div. Try to pass dwr_frame
element.
See fiddle
Upvotes: 1
Reputation: 77
max-brodin is correct. This should fix your problem.
var lengthInd = el.parent().find('.lengthIndicator');
console.log(el.parent().find('.lengthIndicator').val());
Upvotes: 1