Dart uses query('#selector')
if i wanted to get a reference to the result so i can do something with the selected item, what is the dart equivalent. I tried query(this)
but
If you need to use jQuery(this)
or $(this)
for the purpose of retrieving the target of an event:
$('.foo').click(function() {
console.log($(this).hasClass('bar'));
});
In Dart you can write that like:
query('.foo').onClick.listen((MouseEvent e) {
print(e.target.classes.contains('bar'));
});
The Document.query(selector)
function is not an equivalent of jQuery(selector)
but an equivalent of Document.querySelector(selector)
. Thus you cannot get the selector used and you have to keep the reference aside.
If you want to use jQuery in Dart you can use it with the js package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With