I have a div, which onclick calls a javascript function. But it fails to do so when i call the javascript with an argument in it. This is very weird.
This below code calls the function deals() on clicking the button ‘deals’
$("#content").append('<div class="malldetails"><a href="javascript:void(0);"><button class="left" onclick="deals()">Deals</button></a></div>');
function deals(){
alert("This works");
}
But the code below doesn’t work.
$("#content").append('<div class="malldetails"><a href="javascript:void(0);"><button class="left" onclick="deals(mallName)">Deals</button></a></div>');
function deals(NameOfMall){
alert("This does not work");
}
I believe it should be a small problem, but just not able to figure it out. Please help me out Brilliant coders! thanks a lot!
You have to use quotes around mallName