0
我有以下代码。它由一条带有标记的线组成。我为线条和标记写了点击事件。但是当我点击标记元素时,click事件不起作用,并且像游标类型这样的CSS属性也没有设置。如何编写标记元素的点击事件并应用CSS属性?点击事件不适用于连接到行尾的标记
$("#line12").on("click",function() {
alert("Hai You clicked the line")
})
$("#arrow").on("click",function() {
alert("Hai You clicked the line")
})
#line12
{
cursor:pointer;
}
#arrow
{
cursor:pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<svg width="600px" height="200px">
<defs>
<marker id="arrow" markerWidth="10" markerHeight="10" refx="0" refy="3" orient="auto" markerUnits="strokeWidth">
<path d="M0,0 L0,6 L9,3 z" fill="#000" />
</marker>
</defs>
<line x1="50" y1="50" x2="250" y2="150" stroke="#000" id="line12" stroke-width="5" marker-end="url(#arrow)" />
</svg>
它不工作。标记未附加到行的末尾。 –
不要尝试移动标记。在创建之前移动位置并使用div的边框宽度创建箭头 –