How do you reference the current selector, as in jquery $ (this) inside the dart

Dart uses query('#selector')

if I wanted to get a link to the result, so that I could do something with the selected item, which is equivalent to a dart. I tried query(this) but

+4
source share
2 answers

The Document.query(selector) function is not the jQuery(selector) equivalent, but the Document.querySelector(selector) equivalent. Thus, you cannot use the selector, and you need to leave the link aside.

If you want to use jQuery in Dart, you can use it with js .

+3
source

If you need to use jQuery(this) or $(this) for the purpose of event assignment:

 $('.foo').click(function() { console.log($(this).hasClass('bar')); }); 

In Dart, you can write like this:

 query('.foo').onClick.listen((MouseEvent e) { print(e.target.classes.contains('bar')); }); 
+6
source

All Articles