Reputation: 1359
I am having a svg file ,there i need to get the particular path id using javascript or jquery. How can i do this?
$(document).ready(function(){
$("svg").click(function(){
$(this).find("#lay7").css("fill",color);
});
});
Instead of giving id ("lay7") of path directly i need to get the id dynamically.
REf:http://jsfiddle.net/BKAHg/
Upvotes: 1
Views: 2371
Reputation: 5608
try this
$("svg").delegate("*", "click", function(e) { $(this).css('fill', color) })
Upvotes: 1
Reputation: 124049
That's just the $(this) object itself. Oh and you want to attach the click handler to the path I imagine too.
$(document).ready(function(){
$("path").click(function(){
$(this).css("fill",color);
});
});
Upvotes: 1