使用 setAttribute 添加的属性不会被行为处理
例如,如果我正在执行 a.setAttribute("begin", b+".focus");
它会显示在开发工具的 HTML 选项卡中,但它完全被 行为(如果我添加begin="time1.focus"
直接在 html 中工作就很好了)。
如何向行为公开这些动态添加的属性?
还有其他方法可以添加它们吗? (createElement 和 document.write 除外)
PS:我已经尝试使用 createAttribute + nodeValue + setAttributeNode 无济于事。
For example if I am doing a.setAttribute("begin", b+".focus");
it shows up in the HTML tab of the dev tool but it's completely ignored by the behavior (if I add begin="time1.focus"
directly in the html it works just fine).
How do you expose these dynamically-added attributes to the behavior?
Is there another way to add them? (createElement and document.write excluded)
PS: I have already tried using createAttribute + nodeValue + setAttributeNode to no avail.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
秘密在于顺序:您需要在添加行为的类或使用
addBehavior
。The secret is the order: you need to set the attributes before adding the behavior's class or using
addBehavior
.