Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用jQuery更改选项卡_Javascript_Jquery_Html - Fatal编程技术网

Javascript 使用jQuery更改选项卡

Javascript 使用jQuery更改选项卡,javascript,jquery,html,Javascript,Jquery,Html,我正在尝试更改td的点击背景色。这就是我目前使用的JavaScript: $(document).ready(function() { $('#leftHoldNav table td').click(function(){ var $this = $(this); $this.addClass('highlight'); $this.parent().siblings('table').find('td').removeClass('highlight'); }); }

我正在尝试更改td的点击背景色。这就是我目前使用的JavaScript:

$(document).ready(function() {
$('#leftHoldNav table td').click(function(){
    var $this = $(this);
    $this.addClass('highlight');
    $this.parent().siblings('table').find('td').removeClass('highlight');
});
});
这是我为HTML所做的:

    <div id="leftHoldNav">
    <center>
    <table cellpadding="0" cellspacing="0">
    <tr>
        <td onclick="loadPage('../about/info.php','#mainWrapLoad','../about/')" class="highlight">Info</td>
        <td onclick="loadPage('../about/kcintl.php','#mainWrapLoad','../about/')" class="">KC Int'l</td>
        <td onclick="loadPage('../about/board.php','#mainWrapLoad','../about/')" class="">Board</td>
        <td onclick="loadPage('../about/dcon.php','#mainWrapLoad','../about/')" class="">D-Con</td>
    </tr>
    </table>
    </center>
    </div>
没用了,有人知道为什么吗

你不需要回到父母身边,留在兄弟姐妹身边

好了:

$('#leftHoldNav table td').click(function(){
    var $this = $(this);
    $this.addClass('highlight').siblings('td').removeClass('highlight');
});
你不需要回到父母身边,留在兄弟姐妹身边

好了:

$('#leftHoldNav table td').click(function(){
    var $this = $(this);
    $this.addClass('highlight').siblings('td').removeClass('highlight');
});

它现在似乎运转正常。非常感谢@杰克·马丁内斯,不客气!希望链接的方法是明确的…:它现在似乎运转正常。非常感谢@杰克·马丁内斯,不客气!希望链接的方法是明确的…: