因此,我使用jqPlot,它有这个愚蠢的要求,它需要一个元素的id
属性来绘图。获取一个元素的ID没有?
但是,我的JavaScript使用jQuery,它对元素进行操作,而且我不想依赖具有id的div。
我可以在某种程度上给定一个jQuery $(this)
元素,为div生成一个id
,并将该ID传递给我的jqPlot函数?
事情是这样的:
(function($){ //jquery plugin style
$.fn.myPlot = function(){
//Somehow get id for "this"
var generatedId = somehowCreateID(this);
jqPlot.plot(generatedId);
}
})(jQuery);
任何提示赞赏!