我在jquery中有一个函数,如下所示
function findMax(){
$( ".elements" ).each(function( ) {
if($(this).css('z-index')>max1)
max1=$(this).css('z-index');
max1=parseInt(max1);
});
}
我必须在Dart语言中实现此功能。在使用.each函数和'this'函数时遇到语法问题。
答案 0 :(得分: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)
});
在Dart中:
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
});