M
M
Maxim2021-12-14 19:18:02
JavaScript
Maxim, 2021-12-14 19:18:02

How to use jQuery to check the contents of a table cell and fulfill a condition?

Welcome all!
The essence of the task is as follows:
On the checkout page (woocommerce) , you need to check the name of the product, and if it contains the word Airport , then hide the input id="ticket_number" and show the input id="address".

The product name is displayed:

<td class="product-name">Аэропорт - Центр города</td>
if it can help

in any way, thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nadim Zakirov, 2021-12-14
@GMD

Try like this:

<script>
$(function() {
    if ($('td.product-name:contains("Аэропорт")').length > 0) {
        $('input#ticket_number').hide();
        $('input#address').show();
    }
});
</script>

Insert before closing tag</body>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question