使用jQuery th hide when search table with jQuery在搜索表上回答上一个问题之后,当input
字段搜索清除时,如何显示搜索前的初始列?当前,我必须在计算机上单击“输入”栏以显示初始列。
我尝试了$(input#search)[0].reset();
以及基于:reset
Selector for form的建议-包括reset
button
-,但是没有。工作。我是jQuery的新手,因此,我的理解非常有限...
当前的jQuery脚本:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"/>
<script>
<![CDATA[
var allRows = $("#result tr:has(td)");
$("input#search").on("keydown keyup", function() {
allRows.hide();
$("tr:contains('" + $(this).val() + "')").show();
});
$(input#search)[0].reset(); //to reset search table
]]>
</script>
和xsl
代码:
<script src="https://www.kryogenix.org/code/browser/sorttable/sorttable.js"/>
<table class="sortable table-5" id="result">
<caption>List of “What Result”
<input class="input-table-5" type="search" id="search" placeholder="Search..." aria-label="Search"/>
<input type="reset" id="reset" />
</caption>
<tr>
<th>Occur.</th>
<th>What Result</th>
<th>What Context</th>
<th>What Sphere</th>
<th>vs AE</th>
<th>vs clan</th>
</tr>
<xsl:for-each select="./key('persName', @ana)//ancestor-or-self::interp">
<tr>
<td>
<a href="../corpus_ilimilku.html#{.//ref[@n='1']/tokenize(@target)!substring-after(., '#')}" id="{@xml:id}"
onclick="window.open(this.href, 'mywin',
'left=20,top=20,width=1200,height=250,toolbar=0,resizable=0'); return false;" >
<xsl:value-of select="./replace(replace(replace(tokenize(@ana)!substring-after(., '#'), '_', ':'), 'l', ''), 'ktu', 'KTU ')"/>
</a>
</td>
<td><xsl:value-of select=".//ref[@n='2']/stage/key('whatResult-interp', @ana)/catDesc"/></td>
<td><xsl:value-of select=".//ref[@n='5']/placeName/key('whatContext-interp', @ana)/catDesc"/></td>
<td><xsl:value-of select=".//ref[@n='6']/span/key('whatSphere-interp', @ana)/catDesc"/></td>
<td><xsl:value-of select=".//ref[@n='3-2a']/persName/key('person', tokenize(@ana, '\s+')[1])/persName/node()[@n = '1b']"/></td>
<td>
<!-- other data -->
</td>
</tr>
</xsl:for-each>
</table>
预先,非常感谢您的帮助。