【问题标题】:get attr svg polyline获取 attr svg 折线
【发布时间】:2014-08-06 00:07:50
【问题描述】:

html

<svg>
  <polyline points="0,0 100,100" style="fill:none;stroke:black;stroke-width:3"/>
</svg>

jquery

 $("svg").css("width",$(document).width());
        $("svg").css("height",$(document).height()-10);
    $("polyline").click(function(){

        alert($(this).attr("points"));

    });

结果

对象SvgPointList

问题

如何获得 attr svg 积分?

【问题讨论】:

  • 这是 jQuery 吗?如果是什么版本?对我来说似乎工作得很好,请参阅jsfiddle.net/YJQ3c

标签: svg polyline


【解决方案1】:

为什么不尝试使用简单的 javascript 获取 'points' 属性

我将 id 赋予折线

<polyline id="polyline_1" points="0,0 100,100" style="fill:none;stroke:black;stroke-width:3"/>

现在是 Javascript:-

var polyline =document.getElementById('polyline_1');
var points=polyline.getAttribute('points');

它会返回字符串。

【讨论】:

    猜你喜欢
    • 2021-12-23
    • 1970-01-01
    • 2011-10-13
    • 2019-04-11
    • 2020-05-04
    • 2021-10-18
    • 2019-05-24
    • 2018-09-01
    • 2018-05-12
    相关资源
    最近更新 更多