I’m trying to write an html MUD game with javascript.
I try to print a message that shows a picture of the character performing the action when moused over.
Here is my code so far
function printMessage(message,char){
$("#messageScreen").append('<p onmouseover="showPicBottom('+char.race+','+char.pic+')" onmouseout="removePic()">'+""+message+"</p>");
}
function showPicBottom(race,pic){
var pichtml="";
if (origin=="Human"){
pichtml='<img src="img/human/'+"Pic ("+pic+")"+'.PNG"/ width="200">';
}else{
pichtml='<img src="img/elf/'+"Pic ("+pic+")"+'.PNG"/ width="200">';
}
$("#picBottom").append(pichtml);
}
I always get “Uncaught SyntaxError: Unexpected token ‘,'”. I think it’s the quotation marks but I haven’t found a way. How do I fix it?