简体   繁体   中英

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.

尝试使用.text()而不是.val()

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM