加载SVG动画onclick [英] Loading SVG animation onclick
本文介绍了加载SVG动画onclick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用onclick函数使用javascipt在DIV标记内加载SVG动画,
这是带有加载函数的代码,如何通过单击页面上的html菜单项来加载SVG?
Hi,
I`m trying to load an SVG animation inside a DIV tag using javascipt using onclick function,
Here is the code with the load function, how can I make the SVG load by clicking an html menu item on my page?
$(function(){
$("#stage").load('interactive.svg',function(response){
$(this).addClass("svgLoaded");
if(!response){ // Error loading SVG
$(this).html('Error loading SVG. Be sure you are running from a the http protocol (not locally) and have read <a href="http://tympanus.net/codrops/?p=13831#the-javascript">this important part of the tutorial</a>');
}
});
});
推荐答案
( function (){
( #stage)。load(' interactive.svg', function (响应) {
("#stage").load('interactive.svg',function(response){
( this )。addClass( svgLoaded);
if (!response){ // 加载SVG时出错
(this).addClass("svgLoaded"); if(!response){ // Error loading SVG
这篇关于加载SVG动画onclick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文