I
I
Ilya Alekseev2015-11-03 18:49:17
JavaScript
Ilya Alekseev, 2015-11-03 18:49:17

How to make jQuery selector work?

The code doesn't work...
There is a div with id-orders, it has a table in react-e with id-table, it is necessary that after clicking on a row of the table, the code is executed. In the file it is written like this

$("#orders > #table > tbody > tr").click(function(){
      console.log("работает");
    });

I open it in the browser - and nothing happens after clicking on the row, BUT if I copy this code to the console and execute it, then after that the click works.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Ineshin, 2015-11-03
@ilyaalekseev

Will not work because event delegation !
And anyway, why do you need jQuery in react? Do as react wants: In
general, such a record of selectors ("#orders > #table > tbody > tr") is a complete bad manners. All elements should have classes, especially those that you plan to click.

R
Rikcon, 2015-11-03
@Rikcon

wrap in

$(document).ready(function(){

});

did not forget ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question