matthewb
matthewb

Reputation: 3476

jquery attr use variable?

Are you able to place a variable into attr of src?

Example:

$("#member-image2").attr({src : image});        

I am using facebook connect and the "image" is their variable and "member-image2" is my img ID ..

Is this even possible? Because as is, it is not doing it.

Upvotes: 1

Views: 5049

Answers (2)

matthewb
matthewb

Reputation: 3476

Solved:

$("#member-image2").attr({src : ''+image+''});

Had to just trick to be a string..

Upvotes: 1

FrankBr
FrankBr

Reputation: 237

yes you can, but what does the image var say if you alert or log it ?

Is it a valid url ?

Upvotes: 0

Related Questions