admin管理员组文章数量:1304100
The first row is the container for search results to be displayed after user types in a keyword and hit search. The second row displays 5 random news results automatically the first time the website loads with no user queries. after the site loads, user types in some keyword and hit search. Now both the results returned as per user keyword and the 5 news pieces will be there. Based on whether the url has any querystring appended to it, if yes, I need to hide the second row. How do i select the second row?
Let's say if the url is just: http://mysite/news/pages/default.aspx then don't do anything if the url is sth like http://mysite/news/Pages/default.aspx?k=city, then hide the second row...
<div class="NewsResultsList">
<table border="1" id="table">
<tr><td>News Results based on user queries</td></tr>
<tr><td>Random news results</td></tr>
</table>
</div>
The first row is the container for search results to be displayed after user types in a keyword and hit search. The second row displays 5 random news results automatically the first time the website loads with no user queries. after the site loads, user types in some keyword and hit search. Now both the results returned as per user keyword and the 5 news pieces will be there. Based on whether the url has any querystring appended to it, if yes, I need to hide the second row. How do i select the second row?
Let's say if the url is just: http://mysite/news/pages/default.aspx then don't do anything if the url is sth like http://mysite/news/Pages/default.aspx?k=city, then hide the second row...
<div class="NewsResultsList">
<table border="1" id="table">
<tr><td>News Results based on user queries</td></tr>
<tr><td>Random news results</td></tr>
</table>
</div>
Share
Improve this question
edited Jul 27, 2017 at 11:27
Brian Tompsett - 汤莱恩
5,89372 gold badges61 silver badges133 bronze badges
asked Apr 4, 2012 at 16:51
Anjana SharmaAnjana Sharma
4,7655 gold badges40 silver badges51 bronze badges
1
-
1
Not sure if you're suggesting that the script should sniff the URL. Don't do that. Instead, handle the emptying of the table in the
success
function of your callback, or do it server side if that's where things are rendered. – Michael Haren Commented Apr 4, 2012 at 16:56
4 Answers
Reset to default 3Another option is $(".NewsResultsList table tr :nth-child(2)").hide();
.
Take a look to this selector
$(document).ready(function (){
$('div.NewsResultsList table tr:eq(1)').remove()
})
here's the live example
Note : you should change the id of the row to other name because with that id you could create confusion in your code
//This will hide the second row of the table.
$(".NewsResultsList table tr").eq(1).hide();
For reference: http://api.jquery./eq/
Many solutions. This is one I can think of:
$("#table").first().next().hide();
本文标签: javascriptHide second row of table jQueryStack Overflow
版权声明:本文标题:javascript - Hide second row of table jQuery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741781091a2397314.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论