推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Cheez
V2EX  ›  Python

怎么样才能设置 dom 的属性 role?

  •  
  •   Cheez ·
    PRO
    · Aug 25, 2018 · 2003 views
    This topic created in 2840 days ago, the information mentioned may be changed or developed.

    var but=document.createElement('button') but.className='Select-option' but.id='show-image-only' but.innerText='ABC' but.tabindex='-1' but.setAttribute('role','option') this.append(but)

    但是最后 button 元素却没有 role 这个属性,可能是因为他这个时候还没有父母

    2 replies    2018-08-25 22:48:38 +08:00
    l0ng
        1
    l0ng  
       Aug 25, 2018 via Android
    如果是你说的原因,那就最后两句顺序换一下咯
    Cheez
        2
    Cheez  
    OP
    PRO
       Aug 25, 2018
    @l0ng #1 最后直接 cloneNode 了.一阵折腾,终于做出了个成品:https://greasyfork.org/zh-CN/scripts/371548-%E7%9F%A5%E4%B9%8E%E7%9C%8B%E5%9B%BE%E8%84%9A%E6%9C%AC
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5797 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 03:00 · PVG 11:00 · LAX 20:00 · JFK 23:00
    ♥ Do have faith in what you're doing.