Abhilash
Abhilash

Reputation: 2953

change value of next element jquery

I have an input field and span like below and want to replace the text in the span.

<div>
       <input autofocus="autofocus" type="email" value="" name="buyer_signup_email" id="buyer_signup_email" autocomplete="off">
       //want to change below elements text
       <span class="help-block red-text">will change this text</span>
</div>

I tried this but not working

$('input[name="buyer_signup_email"]').next().val('dd')

Could someone tell me whats wrong here? Thank you.

Upvotes: 0

Views: 1247

Answers (1)

stackoverfloweth
stackoverfloweth

Reputation: 6917

try using .text() instead of .val()

$('input[name="buyer_signup_email"]').next().text('dd')

Upvotes: 1

Related Questions