简体   繁体   English

如何通过使用其类名获取SV​​G元素

[英]How do I get SVG element by using its Classname

My Sample Svg : 我的样本Svg:

<circle cx="205.45282275086475" cy="187.9788644175314" r="69.64553108419807" id="07539aec-9d5d-4747-8878-0da5d505cb5f" stroke="#010101" fill="none" stroke-width="2" data-pdf-annotate-id="07539aec-9d5d-4747-8878-0da5d505cb5f" data-pdf-annotate-type="emptycircle" onload="init(evt)"class="hide000000003d495a02706fb486" aria-hidden="true" transform="scale(0.6) rotate(0) translate(0, 0)" style="cursor: pointer;"></circle>

How I have to get the element by using its className 我如何通过使用其className获取元素

var prev_annotation = document.getElementsByClassName("hide000000003d495a02706fb486");
console.log(prev_annotation) // Am not getting the Element

What I have done Wrong? 我做错了什么?

Looks like you have misplaced " . 您似乎放错了地方"

Please try dividing this single line in multiple lines so that you can clearly read your code. 请尝试将此单行分成多行,以便您可以清晰地阅读代码。

<circle cx="205.45282275086475" 

cy="187.9788644175314" 

r="69.64553108419807" 

id="07539aec-9d5d-4747-8878-0da5d505cb5f"

stroke="#010101" 

fill="none" 

stroke-width="2" 

data-pdf-annotate-id="07539aec-9d5d-4747-8878-0da5d505cb5f" 

data-pdf-annotate-type="emptycircle" 

onload="init(evt)" 

class="hide000000003d495a02706fb486【**】 __web-inspector-hide-shortcut__" 

aria-hidden="true" 

transform="scale(0.6) rotate(0) translate(0, 0)" 

style="cursor: pointer;"></circle>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在svg中使用javascript onmouseover函数获取类名? - How do I use javascript onmouseover function with svg to get classname? 如何在元素循环内获取元素的className? - How do I get element's className inside loop of elements? 如何查询 SVG 元素并获取其标题? - How to query an SVG element and get its title? 使用JavaScript,如何使用getElementByClassName获取具有位于另一个元素内的特定className的元素? - Using JavaScript, how do you get elements with a specific className that's inside another element by using getElementByClassName? 如何使用 d3js 获取 svg 元素的宽度? - How do I get the width of an svg element using d3js? 如何从使用变换动画的 SVG 元素中获取样式属性值? - How do I get a style property value from an SVG element that is animated using transform? 如何让SVG解析器呈现单个组元素? - How do I get an SVG parser to render a single group element? 如何在不渲染的情况下获得svg元素的填充颜色? - How do I get the fill color of an svg element without rendering it? 如何使用JavaScript获取缩放的SVG元素的宽度? - How do I get the width of a scaled SVG element with JavaScript? 如何获取分组svg元素的全局坐标? - How do I get the global coordinates of a grouped svg element?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM