使用 setAttribute 添加的属性不会被行为处理

发布于 2024-12-23 08:05:59 字数 407 浏览 3 评论 0原文

例如,如果我正在执行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱花落人离去 2024-12-30 08:05:59

秘密在于顺序:您需要在添加行为的类或使用 addBehavior

The secret is the order: you need to set the attributes before adding the behavior's class or using addBehavior.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文