Answer the question
In order to leave comments, you need to log in
Loading svg into a page from a directory?
Here is an example for uploading images.
$('button').click(function(){
var idImg = $(this).data('icon');
$('div').html('<img src="/images/ico/'+idImg+'.png">');
});
Answer the question
In order to leave comments, you need to log in
You can get the contents of the svg with an ajax request, create an element from this string and add it to the DOM.
$('button').click(function(){
$.get("/some.svg", function(data) {
var svgEl = $(data);
$('div').empty().append(svgEl);
}, 'text');
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question