1

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?

3 Answers 3

3

you can use

alert($(ele).val());

or

alert($(this).val());
Sign up to request clarification or add additional context in comments.

Comments

2

You need to turn ele into a jQuery object:

alert($(ele).val());

Comments

2

The ele parameter to the .each callback is a single DOM element, not a jQuery object.

You should either:

  1. use the native DOM property - ele.value, or

  2. convert ele back into a jQuery object - $(ele).val()

NB: within the callback, this === ele

Comments

Your Answer

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.

Ask question

Explore related questions

See similar questions with these tags.