I'm appending some html codes on javascript. I'm also binding an onclick to it. The problem is, I'm getting a javascript error each time I press onclick. I'm passing a string to the function onclick. Here's a clearer view.
var propertyTypeDdlValues = "";
propertyTypeDdlValues += "<li onclick='selectPropertyType('Condominium/Studio')'>Condominium/Studio</li>";
$("#propertyTypeDdl").html(propertyTypeDdlValues);
This is my selectPropertyType
function selectPropertyType(cattype){
$("#propertyType").text(cattype);
$("#hdnPropertyType").val(cattype);
}
I keep on having this error:
Uncaught SyntaxError: Unexpected token }
I think the problem is how I wrap strings around (" "). What made me say this? Because when I try to just use a simple function like this:
propertyTypeDdlValues += "<li onclick='displayMessage()'>Condominium/Studio</li>";
function displayMessage(){
alert("Message");
}
It goes through the function and the alert message is being displayed.
Any ideas? Thanks!
Condominium/Studio.