开发者

YUI Get class name by id

开发者 https://www.devze.com 2023-01-20 18:09 出处:网络
Is there a syntax for getting the class name by id. The class name is dynamic so I can\'t use if(Dom.hasClass(\'id-name-here\', \'class-name-here\')

Is there a syntax for getting the class name by id. The class name is dynamic so I can't use

if(Dom.hasClass('id-name-here', 'class-name-here')
{
  Dom.removeClass('id-name-here', 'class-name-here');
  Dom.addClass('id-name-here', 'class-name-here');
}

I can get the src attribute using the id by doing this,

Dom.get('id-name-here').src

But when I try to adapt it to class, it is undefined

Dom.get('id-name-he开发者_StackOverflow中文版re').class

I am only certain of the id. Can you point me to the right documentation or teach me how...Thank you!


I think, it is className rather than class:

Dom.get('id-name-here').className;
0

精彩评论

暂无评论...
验证码 换一张
取 消