james
james

Reputation: 2663

Jquery Quoting String

I cannot seem to get the quotes around this statement right. No matter what combination I try. I am really confused on how it should be quoted.

$(#imagearea).append("<img id='"+theWord.charAt(i).toUpperCase+"'.png'" src='images/'+theWord.charAt(i).toUpperCase+"'.png'/>");

Upvotes: 0

Views: 120

Answers (4)

codelove
codelove

Reputation: 2016

Make it less confusing by putting it in two lines.

var myChar = theWord.charAt(i).toUpperCase();
$('#imagearea').append('<img id="'+myChar+'.png" src="images/'+myChar+'.png" />');

Upvotes: 3

sujal
sujal

Reputation: 1050

$('#imagearea').append("<img id='"+theWord.charAt(i).toUpperCase+".png' src='images/"+theWord.charAt(i).toUpperCase+".png'/>");

Try this one

one main mistake is $('#imagearea'), u have missed the single quotes

Upvotes: 0

grc
grc

Reputation: 23555

Try this:

$('#imagearea').append("<img id='"+theWord.charAt(i).toUpperCase+".png' src='images/"+theWord.charAt(i).toUpperCase+".png' />");

It should append this:

<img id='x.png' src='images/x.png' />

Upvotes: 1

mowwwalker
mowwwalker

Reputation: 17334

$('#imagearea').append("<img id='"+theWord.charAt(i).toUpperCase+".png'  src='images/'"+theWord.charAt(i).toUpperCase+".png'/>");

Upvotes: 0

Related Questions