简体   繁体   中英

How to access 'fill' element of circle tag in sahi code

I want to access the fill element of circle tag in <svg> tag and assign the value to a variable.

fill value is #08C65B .

I tried with the below line but unable to get it:

document.getElementsByTagName("svg")[0].document.getElementsByTagName("circle")[0].getAttribute("fill")

var y = document.getElementsByTagName("svg"[0].document.getElementsByTagName("circle")[0].getAttribute("fill")

在此处输入图片说明

let querySelector = document.getElementsByTagName("svg")[0]
let circleSelector = querySelector.getElementsByTagName("circle")[0]
let filledAttribute = circleSelector.getAttribute("fill")

or

Instead of using

document.getElementsByTagName("svg")[0].document.getElementsByTagName("circle")[0].getAttribute("fill")

Use

document.getElementsByTagName("svg")[0].getElementsByTagName("circle")[0].getAttribute("fill")

Sahi 有一个get 属性 API和一个圆选择器所以应该可以做一个_getAttribute(_svg_circle($selector), "fill")

这有效 document.getElementsByTagName("circle")[0].getAttribute("fill"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM