View Full Version : Use of variables
07-21-2010, 01:54 AM
Noob here. Please bear with me.http://www.codingforums.com/images/smilies/tongue.gif
<span title="this is the title">....</span>
I need to use variables for the title instad of text.
Please advise. Thank you.
07-21-2010, 02:43 AM
var sptitle = "This is title number " + (++counter);
var spcontents = "Now the number is " + counter;
document.write('<span title="' + sptitle + '">' + spcontents + '</span>');
Is something like that what you are talking about??
You could also do it via:
document.getElementById("whatsit").title = "tick " + Math.random() + " tock";
07-21-2010, 02:55 AM
Better the first option. It keeps the <span> unique.
07-21-2010, 03:10 AM
It keeps the <span> unique.
??? No more so than the second one. Either set of code could produce the results of the other set. It was all made-up arbitrary code.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.