I am using Raphael to draw SVG elements.
For example, if I have SVG element
<image x="710" y="425" width="10" height="10" preserveAspectRatio="none" href="images/car.png" style="cursor: pointer;"/>
How can I access each attribute in JavaScript (further more, the access method should also be functional in IE)
give the image an id element, eg
<image id="myImage" x="710" y="425" width="10" height="10" preserveAspectRatio="none" href="images/car.png" style="cursor: pointer;"/>
and after access it via jQuery using
$('#myImage').attr("width"); // getter
$('#myImage').attr("width", "400"); // setter
greetings
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.