[英]how to get value of element which have particular class and id?
i want to get transform attribute of particular id and class using java script not jquery?我想使用 java 脚本而不是 jquery 获取特定 id 和 class 的转换属性? is there any solution to select a specific element, specifying both the class and id ?
是否有任何解决方案来选择特定元素,同时指定 class 和 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我想获得与匹配 id 和 class 对应的转换属性
You can use document.querySelector()您可以使用document.querySelector()
const selector = document.querySelector("#748588.Selection")
const transformValue = selector.getAttribute("transform")
使用getElementById获取元素,然后可以从元素style
对象中获取transform
属性:
document.getElementById("748588").style.transform
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.