Here is the test code:
var current_page= 0;
$('#background_music').append('<img id="bm'+current_page+'" src="success.png" width="68px" height= "68px"/>');
$("#"+ "bm'+current_page+'").offset({top: 171, left: 41});
In this example, it doesn't work since the image won't give the expected offset. What's wrong with this:
"bm'+current_page+'"
However, if I change this to
$("#"+ "bm"+current_page).offset({top: 171, left: 41});
It works.
- What is the difference?
- Doesn't the code
" bm'+current_page+' "
generate a string:"bm0"
?
Update: 1. What's the difference? I just can't figure it out this +variable+. In my past question, I have posted such a similar one. However, I didn't figure it out after all...