We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 44cd157 + 2ccb587 commit 58a32dbCopy full SHA for 58a32db
query.go
@@ -179,6 +179,19 @@ func SelectAttr(n *html.Node, name string) (val string) {
179
return
180
}
181
182
+// ExistsAttr returns whether attribute with specified name exists.
183
+func ExistsAttr(n *html.Node, name string) bool {
184
+ if n == nil {
185
+ return false
186
+ }
187
+ for _, attr := range n.Attr {
188
+ if attr.Key == name {
189
+ return true
190
191
192
193
+}
194
+
195
// OutputHTML returns the text including tags name.
196
func OutputHTML(n *html.Node, self bool) string {
197
var buf bytes.Buffer
0 commit comments