I have the following HTML markup :
<a class="link1" href="javascript:load(0,1);">Click here</a><span class="loader"></span>
The load function is defined as follows :
function load(flag,id){
/*Load Forum*/
if(flag==0){
$(this).next("span.loader").html("<img src='./images/loader.gif'/>");
console.log("Here");
//....Some code follows
So what I want is the preloader gif should appear beside the link when it is clicked. The 'console.log' is printing 'Here' to the console but the image is not appearing. The image is located at the correct address. I think there is problem in the way I am using the 'this' keyword. Any help would be appreciated. Thanks. :)
Updated: As it was pointed out by some, I passed reference to the element by passing this as an argument. Here is my code now but it does not work still :
<a class="link1" href="javascript:load(0,1,this);">Click here</a><span class="loader"></span>
function load(flag,id,ref){
/*Load Forum*/
if(flag==0){
if(ref){ $(ref).next("span.loader").html("123");console.log("Here"); }