Tatters
Tatters

Reputation: 1197

val() on iPhone iOS not returning textarea value

The following val() call from a textarea is working fine on Firefox/Chrome on my desktop and laptop but on iPhone (safari) nothing is returned? I'm not sure what part of the iOS system stops this from working? Javascript is 'On' in settings.

$('textarea[name=username]').val()

Thanks

Upvotes: 0

Views: 1279

Answers (1)

lukenofurther
lukenofurther

Reputation: 553

If anyone's looking for an answer to this, $().val() doesn't seem to work on iPhone, either as a getter or a setter. Instead, use $().attr('value') like this:

Getter

$('textarea[name=username]').attr('value');

Setter

$('textarea[name=username]').attr('value', 'elonmusk');

Upvotes: 2

Related Questions