Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I have that Jquery code:
$('input[name*="fotos[]"]').each(function (i, ele) { alert(ele.val()); });
but I get that error in browers:
Error: TypeError: ele.val is not a function
what is wrong here?
you can use
alert($(ele).val());
or
alert($(this).val());
Add a comment
You need to turn ele into a jQuery object:
ele
The ele parameter to the .each callback is a single DOM element, not a jQuery object.
.each
You should either:
use the native DOM property - ele.value, or
ele.value
convert ele back into a jQuery object - $(ele).val()
$(ele).val()
NB: within the callback, this === ele
this === ele
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.