i want to get transform attribute of particular id and class using java script not jquery? is there any solution to select a specific element, specifying both the class and id ? for example:
<g id="748588" transform="translate(44 -4)" class="Selection"></g>
And I want to get transform attribute corresponding with match id and class
You can use document.querySelector()
const selector = document.querySelector("#748588.Selection")
const transformValue = selector.getAttribute("transform")
Yes, document.querySelector
will do what you want. Here is the MDN page. In your case, you could use something like:
const my_transform = document.querySelector('#748588.Selection').getAttribute('transform')
使用getElementById获取元素,然后可以从元素style
对象中获取transform
属性:
document.getElementById("748588").style.transform
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.