开发者

jQuery under SVG

开发者 https://www.devze.com 2022-12-20 20:29 出处:网络
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.

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.

As for now the jQuery engine contains some statements like this:

div = document.creat开发者_运维技巧eElement("div");
div.style.display = "none"; 

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?


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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号