Использование usercript для клика на тд из таблицы - PullRequest
0 голосов
/ 23 февраля 2019

Похоже, радио-кнопка, но на самом деле это просто тд.Я знаю, как выбрать обычный переключатель, но как выбрать td?

$ ('input [value = "no"]'). Click ();


Вот как выглядит код таблицы:

<table align="center" width="90%" class="hoverTable">
                <tr style="height: 50px">
                    <td width="85%"><span title="Commonsense about social situations. For example: situations that involve other people and evoke emotions of anger, laughter etc." class="tt">Social Commonsense</span>?</td>
                    <td align="center" width="8%">
                        YES
                    </td>
                </tr>

                <tr style="height: 50px">
                    <td><span title="Commonsense about the physical world. E.g. cars are smaller than garages." class="tt">Physical Commonsense</span>?</td>
                    <td align="center">
                        NO
                    </td>
                </tr>

                <tr style="height: 50px">
                    <td><span title="Commonsense about the biological world. For example: plants are fixed in location, people need to eat food to survive etc." class="tt">Biological Commonsense</span>?</td>
                    <td align="center">
                        NO
                    </td>
                </tr>

                <tr style="height: 50px">
                    <td><span title="Commonsense about how the world works. For example: countries have states, babies crawl before walking etc." class="tt">Man-Made Constructs Commonsense</span>?</td>
                    <td align="center">
                        YES
                    </td>
                </tr>

                <tr style="height: 50px">
                    <td><span title="The order in which events occur in time. For example: you need to turn ignition on before driving a car" class="tt">Temporal Order</span> of events?</td>
                    <td align="center">
                        NO
                    </td>
                </tr>

                <tr style="height: 50px">
                    <td><span title="Commonsense about which agent / person performs the required action. For example: If Person1 apologizes to Person2, Person2 accepts the apology, not Person1." class="tt">Agent-Action Commonsense</span>?</td>
                    <td align="center">
                        NO
                    </td>
                </tr>
                <tr style="height: 50px">
                    <td><span title="Commonsense about where certain events can happen. For example: people typically eat in a restaurant, play in the park etc." class="tt">Spatial / Location Commonsense</span>?</td>
                    <td align="center">
                        NO
                    </td>
                </tr>
            </table>

1 Ответ

0 голосов
/ 23 февраля 2019

Полагаю, вы используете jQuery?

   $('.hoverTable td').click(function() {
    var inVal =  $(this).html();
    var newVal = inVal=='NO'?'YES':'NO';
    $(this).html(newVal)
   });
...