【发布时间】:2019-02-10 11:23:19
【问题描述】:
我看过一堆关于从标题中获取值/文本的帖子,但没有一个解决方案适用于我的特定用例,我怀疑这可能是由于我的标题获得了它的值来自我的底层 python 代码(我正在使用烧瓶)。
<table id="UCNTable" class="table table-striped table-bordered table-sm" cellspacing="0" width="100%">
<thead>
<tr>
<th>
{{ header[0] }}
</th>
<th>
{{ header[2] }}
</th>
<th>
{{ header[3] }}
</th>
<th>
{{ header[4] }}
</th>
<th>
{{ header[5] }}
</th>
</tr>
</thead>
<tbody>
{% for row in data %}
<tr>
<td>
{{row.name}}
</td>
<td>
{{row.Amt}}
</td>
<td>
{{row.OK}}
</td>
<td>
{{row.Err}}
</td>
<td>
{{row.prT}}
</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<th>
{{ header[0] }}
</th>
<th>
{{ header[2] }}
</th>
<th>
{{ header[3] }}
</th>
<th>
{{ header[4] }}
</th>
<th>
{{ header[5] }}
</th>
</tr>
</tfoot>
</table>
<script>
$('#UCNTable tfoot th').each( function () {
var title = $(this).text();
$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
} );
</script>
所以基本上,这应该说“搜索变量”,但它只是说搜索。 关于我做错了什么的任何想法? 我怀疑 JQuery 正在寻找一些文本,但它有一个问题,因为它是一个变量 - 任何帮助表示赞赏! 谢谢。
【问题讨论】:
-
你能告诉我们你烧瓶代码的输出 html吗?
-
@Mosh Feu 呃,是的,当然!图片可以吗? i.imgur.com/FJ9wUJO.png 如果我从 title 变量中删除 .text() 它会说“搜索 [object Object]
-
输出 html :) 所以我们可以尝试调试它。
-
@Mosh Feu 抱歉,我不是网络开发人员,所以我不确定这到底意味着什么!通过在我的页面上检查 (CTRL+SHIFT+I) 可以得到输出 html 吗?
-
@Mosh Feu(我无法编辑我的评论,所以我再写一次)似乎在搜索和 variable
<input type="text" placeholder="Search ERRORProducts ">之间出现了一个流氓换行符
标签: jquery html flask datatables