csserrs
csserrs

Reputation: 23

Javascript - load template in html of element

I have a template that I want to render inside html element on click of element. I want to do something like ( I am using jquery):

$(".btn")on("click", function(){ 
     $("#element").html(partial_template.html)
});

Buto this of course wont work. How can I achieve this?

EDIT: I am using Django, if this matters!

Upvotes: 0

Views: 1212

Answers (1)

Bourbia Brahim
Bourbia Brahim

Reputation: 14712

Use .load() function , make sur to set the right path to your html tpl .

$(".btn").on("click", function(){ 
     $("#element").load("path_to_your_html_folder/partial_template.html");
});

Upvotes: 1

Related Questions