javascript - is there is any easy way to detect attr jquery -
i trying detect if element has attribute not specific . wanna know if there . , if there attr want remove themm , add new attributes . , if there not new attributes added only.
my codes are
if ($('.element').attr('style').length > 0) { $(this).removeattr('style'); } $('.element').css({ "top": (posy), "left":(posx) });
but in console shows uncaught typeerror: cannot read property 'length' of undefined
can 1 help?
try this,
if($('.element').attr('style') && $('.element').attr('style').length > 0){ $('.element').removeattr('style'); } $('.element').css({ "top": (posy), "left": (posx) });
Comments
Post a Comment