javascript - select and compare x or y from a svg rect in jquery
问题描述
How can i select and compare x or y element value from a svg rect in jquery?
svg looks like this:
<svg id="demo" width="100%" height="40" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect id="stretchy" x="20" y="40" width="100%" height="40" fill="#b7b7b7" stroke-width="5"></rect>
<text x="50%" y="50%" font-family="Verdana" font-size="20" text-anchor="middle" dy=".3em"> text </text>
</svg>
I wanna use it in something like this:
if($('#stretchy').css('x')!='20'){
code
}
解决方案
this is the answear to this question:
if($('rect[id="stretchy"]').attr('x')!='20'){ code }
推荐阅读
- docker - 在 localhost 中无法访问 Dockerized Flask 应用程序
- angular - 如何使用 ErrorInterceptor 正确拦截 HTTP 错误并在 Angular10 中创建自定义错误
- wordpress - WordPress 中的 409 期联系表 7
- javascript - 使用 setTransform 旋转矩形时的莫尔效应
- performance - 慢日志包
- sql - 我应该如何组合多列并转换为行?
- html - 用于活动菜单颜色自定义的 HTML 编码
- php - 使用 GET 方法 PHP 在文本字段中获取值
- r - 如何将任何分析摘要中显示的数据复制到数据框中?
- java - 重构后Android Studio无法检测到布局R.id和布局xml无法检测到标签