使用 Jquery 检索文本区域中的 ID

发布于 2025-01-16 09:54:16 字数 453 浏览 0 评论 0原文

我有这个代码

<textarea id="boh" name="boh" rows="4" cols="50">
god save the queen for <span id="godsq">2<span> times</textarea>
<input type="text" id="risultat">

我想找到值 2 并在以下情况下放入输入字段我单击按钮

我尝试了以下代码

$( "#button" ).click(function() {$("#risultat").val($("#godsq").text());} );

但它没有给我结果

I have this code

<textarea id="boh" name="boh" rows="4" cols="50">
god save the queen for <span id="godsq">2<span> times</textarea>
<input type="text" id="risultat">

<button id="button" type="button">Click Me!</button>

I'd Like to find the value 2 and put in the input fiedl when I click the button

I tried the following code

$( "#button" ).click(function() {$("#risultat").val($("#godsq").text());});

But it doesn't give to me result

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文