简体   繁体   English

更改下一个元素jQuery的值

[英]change value of next element jquery

I have an input field and span like below and want to replace the text in the span . 我有一个input字段和span如下所示,想replace spantext

<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')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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