JQuery-添加内容,独立于wordpress主题

JQuery-添加内容,独立于wordpress主题,jquery,Jquery,我想在JQuery的帮助下编写一个简单的函数。我创造了这把小提琴: <table class="my_table"> <tr> <td class="correct"></td> <td> <input type="button" class="my_button" /> </td> </tr> <t

我想在JQuery的帮助下编写一个简单的函数。我创造了这把小提琴:

<table class="my_table">
    <tr>
        <td class="correct"></td>
        <td>
            <input type="button" class="my_button" />
        </td>
    </tr>
    <tr>
        <td class="incorrect"></td>
        <td>
            <input type="button" class="my_button" />
        </td>
    </tr>
...

...

单击后,按钮上方会添加一些内容。这是我本地机器上的情况。我在wordpress上运行了另一个主题,代码如下所示:

<table class="my_table">
    <tr>
        <td class="correct"></td>
        <td>
            <div>
            <input type="button" class="my_button" />
            </div>
        </td>
    </tr>
        <tr>
        <td class="correct"></td>
        <td>
            <div>
            <input type="button" class="my_button" />
            </div>
        </td>
    </tr>
...

...

在这里,代码当然不起作用,因为函数中缺少一个parent()。我如何编写此函数,使其始终在单击按钮的同一tr中使用第一个td,从而使其独立于主题


谢谢

这段代码在同一
tr
中查找所有
td
正确的

$('.my_button').click(function() {
   $(this).parentsUntil("tr").siblings("td.correct").html('Test'); 
});

我的回答对你有帮助吗?