Hi this is my JS fiddle
I am trying to add a div set on JavaScript file to append but I am getting undefined jQuery variable error
although I have added external jquery file
Hi this is my JS fiddle
I am trying to add a div set on JavaScript file to append but I am getting undefined jQuery variable error
although I have added external jquery file
You ignored the first error in the console, and looked straight to the second error ($ not being defined) .
http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js
You’re loading that over http, while the jsfiddle is over https. You need to either match protocols or make that jquery call protocol agnostic (//ajax.googleapis.com…etc).
Had you gone to the http version of your jsfiddle, it would work. http://jsfiddle.net/rnzd53a4/2
thanks
now its working fine
next question is I have taken a variable x and I want that variable to increase each time a new block is added
I have also used that variable in my code but that is only getting value 1 each time
anyone on this?
The reason is that the string you’re assigning to block
only gets evaluated once (when x
is 1). To have it evaluated anew each time you’re using it, you’d either have to append()
that string directly, or use a wrapper function that returns the string, like
var block = function() {
return "<div><!-- etc... -->" + x + "<!-- etc... --></div>";
};
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.