问题描述
有什么办法可以在SVG而不是HTML下运行jQuery吗?
Is there any way I can run jQuery under SVG instead of HTML?
我知道但这不是我想要的。
I know about jQuery svg plugin but this is not what I want.
现在jQuery引擎包含一些这样的语句:
As for now the jQuery engine contains some statements like this:
div = document.createElement("div");
div.style.display = "none";
在SVG下jQuery初始化期间失败,因为SVG文档无法创建 div
元素。在jQuery中还有一些其他特定于HTML的地方在SVG下无法预测的地方失败。
It fails with exception during jQuery initialization under SVG because SVG document is unable to create div
element. And there are some other HTML-specific places in jQuery which fail in unpredictable places under SVG.
有什么方法可以解决这个问题吗?
Is there any way to resolve this problem?
推荐答案
我黑客攻击了旧版本的jquery,并且可以通过一些修改在仅svg模式下运行它。随意采取改变,并随心所欲地做任何事情。 ,这里的。
I hacked an old version of jquery around a bit, and it is possible to run it in svg-only mode with some modifications. Feel free to take the changes and do whatever you want with them. Here's a demo and here's the modified jquery sourcecode.
它是如果你想在HTML和SVG中使用它,可能会有一些不完整的问题,但这只是一个开始,至少在一定程度上有效。
It's incomplete and probably has some issues if you want to use it in both HTML and SVG, but it's a start, and works to some extent at least.
这篇关于在SVG下的jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!