I want to use jquery append() using an id as my selector, however the id is stored in a local variable. I have the tried the following code but it is not working. What am I doing wrong?
$('#'+localStorage.productUrl+'').append('<span>item is added</span>');
Here is my code in a fiddle: http://jsfiddle.net/tCuKt/20
I am not sure what do you mean by “this is not working”. but if
localStorage.productUrlcontains id of the element on which you want to append span then it should work .Also ensure your jquery is inside.
see demo:-
http://jsfiddle.net/tCuKt/1/
Edit:- Updated Fiddle
http://jsfiddle.net/tCuKt/25