jQuery:在div内设置表格单元格的值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/937950/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 10:11:41  来源:igfitidea点击:

jQuery: set value of table cell inside div

jquery

提问by Hintswen

I have a floating div which contains a title and I want to change that title. I tried this:

我有一个包含标题的浮动 div,我想更改该标题。我试过这个:

$("div#dragTitle3").text("New Title");

But the title is actually in a table inside the div. This is the table:

但标题实际上是在 div 内的一个表中。这是表:

<table><tbody><tr><td>Announcements</td><td style="text-align:right"><img src="buttontop.png" class="divTitleButton" id="dragButton3" onmousedown="javascript:toggleContentWin(3)"></td></tr></tbody></table>

I want to know how I can change the title without entering the whole table's code when I set the new table.

我想知道在设置新表格时如何更改标题而无需输入整个表格的代码。

回答by Ronald Wildenberg

This should work:

这应该有效:

$("div#dragTitle3 td:first").text("New title")