[removed] Bold all table td entries which contain “*sometext*” on mouse-over

前端 未结 3 1148
执笔经年
执笔经年 2021-01-27 12:34

I have a table element on some page. It contains some table rows with cells, containing hrefs.

My target is: when I point mouse cursor over som

3条回答
  •  Happy的楠姐
    2021-01-27 13:16

    Using jQuery (which you said may be acceptable) it could be something like this:

    $(document).ready(function(){
       $('td > a').hover(
           function() {
               $('td > a:contains("' + this.innerHTML + '")').css('font-weight', 'bold')
           },
           function() {
               $('td > a').css('font-weight', 'normal')
           }
       )
    })
    

    DEMO: http://jsfiddle.net/2ATc5/3/

    When mouse enters anchor within TD - code looks for all anchors within TDs that have the same text and bolds them.

    When mouse leaves the anchor - font-weight returns to normal.

提交回复
热议问题