代码之家  ›  专栏  ›  技术社区  ›  Woppi

YUI通过ID获取类名

  •  1
  • Woppi  · 技术社区  · 15 年前

    是否有按ID获取类名的语法。类名是动态的,因此我不能使用

    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');
    }
    

    通过这样做,我可以使用id获取src属性,

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

    但是当我试图使它适应课堂时,它是未定义的

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

    我只知道身份证。你能给我指出正确的文件或教我如何……谢谢!

    1 回复  |  直到 15 年前
        1
  •  5
  •   Sarfraz    15 年前

    我想,是 className 而不是 class :

    Dom.get('id-name-here').className;
    
    推荐文章