最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Hiding the table border using jquery - Stack Overflow

programmeradmin1浏览0评论

I have a div which which displays dynamically created tables (In a asp repeater actually). The no of tables can be different depending on the items it gets from the database. I have given a sample markup below with the css and the jquery code. Again the table will be dynamically created. I just have given two and did not include the mark inside it.

.todotable{border-bottom:1px solid white;}

<div id="divalert">
<table></table>
<table></table>
</div>

 $(document).ready(function () {
       $("#divalert").last().css("border-bottom", "none");
  });

My question is, how do I remove the border for the last table?

I have a div which which displays dynamically created tables (In a asp repeater actually). The no of tables can be different depending on the items it gets from the database. I have given a sample markup below with the css and the jquery code. Again the table will be dynamically created. I just have given two and did not include the mark inside it.

.todotable{border-bottom:1px solid white;}

<div id="divalert">
<table></table>
<table></table>
</div>

 $(document).ready(function () {
       $("#divalert").last().css("border-bottom", "none");
  });

My question is, how do I remove the border for the last table?

Share Improve this question asked Apr 26, 2012 at 8:32 JoshuaJoshua 2,2958 gold badges42 silver badges57 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

You haven't selected the table. Try one of these:

$("#divalert :last-child").css("border-bottom", "none");

// or

$("#divalert table").last().css("border-bottom", "none");
$("#divalert table:last").css("border-bottom", "none"); // same as above

I'd rather use CSS for this. Using JS when CSS is available is never a good idea :-)

#divalert table:last-child {
    border-bottom: none;
}
发布评论

评论列表(0)

  1. 暂无评论