0

I have the following html snippit;

<input name='first' class="foo" />
<input name='second' class="foo bar" />
<input name='third' class="foo" />

I want to set the value of a specific element, but i'm unable to select the right one. This is whar i've tried:

jQuery('.bar').val('selected');
1

1 Answer 1

1

Seems to be working fine, make sure you are running on dom ready.

$(function() {
    $('.bar').val('selected');
});
Sign up to request clarification or add additional context in comments.

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.