dart:html
庫中Element.querySelector
方法的用法介紹如下。
用法:
Element? querySelector(
String selectors
)
override
查找與指定選擇器組匹配的此元素的第一個後代元素。
selectors
應該是使用 CSS 選擇器語法的字符串。
// Gets the first descendant with the class 'classname'
var element = element.querySelector('.className');
// Gets the element with id 'id'
var element = element.querySelector('#id');
// Gets the first descendant [ImageElement]
var img = element.querySelector('img');
有關 CSS 選擇器語法的詳細信息,請參閱 CSS selector specification 。
相關用法
- Dart Element.querySelectorAll用法及代碼示例
- Dart Element.children用法及代碼示例
- Dart Element.tag用法及代碼示例
- Dart Element.animate用法及代碼示例
- Dart Element.created用法及代碼示例
- Dart Element.insertAdjacentHtml用法及代碼示例
- Dart Element.dataset用法及代碼示例
- Dart Element.html用法及代碼示例
- Dart Element.classes用法及代碼示例
- Dart ElementList.classes用法及代碼示例
- Dart Event.eventType用法及代碼示例
- Dart Enum.compareByIndex用法及代碼示例
- Dart EventStreamProvider.forTarget用法及代碼示例
- Dart Events用法及代碼示例
- Dart EventStreamProvider.forElement用法及代碼示例
- Dart EnumName.name用法及代碼示例
- Dart Enum.compareByName用法及代碼示例
- Dart Error用法及代碼示例
- Dart MapMixin.containsKey用法及代碼示例
- Dart Iterator用法及代碼示例
- Dart AttributeClassSet.intersection用法及代碼示例
- Dart num.sign用法及代碼示例
- Dart TransformList.last用法及代碼示例
- Dart FileList.first用法及代碼示例
- Dart CanvasRenderingContext2D.drawImageScaledFromSource用法及代碼示例
注:本文由純淨天空篩選整理自dart.dev大神的英文原創作品 querySelector method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。