I have the following piece of code which fires on click of a button with class undo
. Here variable cls
gives outputs a3
, a2
etc. as expected, but when I use cls
in
var some = $("path#path"+cls_id).data("id").cls ;
,
I get alert result as undefined
. But when I replaced cls
with a3
or a2
manually, got the result. Complete code:
$('body').on('click','.undo',function () {
var cls_id = $(this).parent().attr('class');
var cls = $(this).attr('data-undo');
var some = $("path#path"+cls_id).data("id").cls;
alert(some);
});
HTML
<path id="path1" stroke="rgb(178, 34, 34)" stroke-width="2" fill="none" d="M683 137 L742 217 L535 301 L513 220" data-id="{ "a1":"L33 24", "a2":"L442 89" }"></path>
Somebody please suggest a way to fix the issue.