如何使用每个函数,从jquery到Dart语言?

Kir*_*mar 1 dart dart-editor dart-webui dart-js-interop

我在jquery中有一个函数,如下所示

function findMax(){
 $( ".elements" ).each(function( ) {
  if($(this).css('z-index')>max1)
  max1=$(this).css('z-index');
  max1=parseInt(max1);
 });
}
Run Code Online (Sandbox Code Playgroud)

我必须在Dart语言中实现这个功能.在使用.each函数和'this'函数时遇到语法问题.

Ale*_*uin 8

相当于jQuery:

$(".elements").each(function( ) {
  // do something with this being one of elements with a 'elements' class
  // you can access the current element with $(this)
});
Run Code Online (Sandbox Code Playgroud)

在达特:

querySelectorAll('.elements').forEach((Element e) {
  // do something with e being one of elements with a 'elements' class
  // you can access the current element with e
});
Run Code Online (Sandbox Code Playgroud)