更改下一个元素jquery的值

时间:2017-03-17 00:25:47

标签: javascript jquery

我有一个input字段和span,如下所示,想replace text 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>

我试过这个但没有工作

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

有人能告诉我这里有什么不对吗?谢谢。

1 个答案:

答案 0 :(得分:1)

尝试使用.text()代替.val()

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