P
P
Pavel2020-05-08 09:15:29
JavaScript
Pavel, 2020-05-08 09:15:29

How to select option selected correctly?

There is a form, inside the table, in the table select , it is necessary to cycle through val from option and depending on val ... that's another story)

$('.table tr').each((index, el) => {
                            const firstTd = $(el).find('.cat').children("option:selected").val();
                            if (firstTd === 13) {
                                console.log("есть 13");
                            }
                        })


https://jsfiddle.net/KLON/z0dxus7w/5/

I can't select val itself from option, what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Ivanov, 2020-05-08
@maksim_fix

const select = $(".select")
if(select.val == "13"){
    alert("13");
}

This is in case only 1 option can be selected

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question