Css需要突出显示表中的常用词

Css需要突出显示表中的常用词,css,Css,我在slate.com上看到过这样一个页面,当您将鼠标悬停在一个实例上时,该页面会突出显示表格中类似的单词: 有人知道这是怎么做到的吗?您可以用jQuery这样做: $('table td').mouseover(function() { $('table td').removeClass('highlight') var text = $(this).text(); $('table td').filter(function() { return $(this).tex

我在slate.com上看到过这样一个页面,当您将鼠标悬停在一个实例上时,该页面会突出显示表格中类似的单词:
有人知道这是怎么做到的吗?

您可以用jQuery这样做:

$('table td').mouseover(function() {
    $('table td').removeClass('highlight')
    var text = $(this).text();
    $('table td').filter(function() { return $(this).text() == text; }).addClass('highlight');
})
使用jQuery.data检查此项

要知道某些东西是如何工作的,第一步是阅读源代码

选中此项:


看看这篇文章,这将适用于所有单词,而不是每一个单词。
$('.interactive_table .cell_word')
    .hover(function(){
        var word = $(this).data('word');
        $(this).parent().parent()
        .find('.word_'+word)
        .addClass('highlighted');
    },function(){
        var word = $(this).data('word');
        $(this).parent().parent()
        .find('.word_'+word)
        .removeClass('highlighted');
});

$('.interactive_table .cell_rank_number')
    .hover(function(){
        $(this).parent()
        .find('.cell_word')
        .addClass('highlighted');
    },function(){
        $(this).parent()
        .find('.cell_word')
        .removeClass('highlighted');
});