I'm writing an app that needs dynamic javascript. I didn't know how to use Django template variable in javascript. when I searched I found some answeres like Django Template Variables and Javascript but I still have the problem. when I write this piece of code in my html :
<script>jQuery(document).ready(function ($) {
$(".nav").css({"opacity": "0.5"});
$("#description").animate({opacity: '+=0.5'}, 10000);
});
</script>
every thing is fine. the navbar is transparent and <p id="description">{{description}}</p>
is shown by jquery animate function. but when i change it to this:
<script>jQuery(document).ready(function ($) {
$(".nav").css({"opacity": "0.5"});
var a = "{{description}}";
$("#description").animate({opacity: '+=0.5'}, 10000);
});
</script>
the navbar is no more transparent and the description is no more shown. what is the problem ?
p.s : I changed a to a = "{{blah}}"; and there is no problem with it. the problem apears when It is a real template variable.