javascript - get id of HTMLDivElement -
i passing htmldivelement in function follows
var tablehtml = "... <li name="item2" onclick="oncombtopie2d(\'' + id + '\');" >pie 2d</li> ...."; $('#graphsdiv').append(tablehtml);
i able access element in function follows
function oncombtopie2d(element) { alert($('#element')); }
but cannot access id of element. have tried following far
alert($('#element').attr('id')); //undefined alert($('#element').prop('id')); //undefined alert(element.id); //undefined
in viewsource div present (which kendo chart)
<div id="chartmd2467rt6" data-role="chart" class="k-chart" style="position: relative; touch-action: none;"> ... </div>
try sample:
function oncombtopie2d(idelemento) { alert($('#'+idelemento).attr('id')); }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <ul> <li name="item2" onclick="oncombtopie2d('chartmd2467rt6');" >pie 2d</li> </ul> <div id="chartmd2467rt6" data-role="chart" class="k-chart" style="position: relative; touch-action: none;"> ... </div>
Comments
Post a Comment