Changing the Value of a Span tag using JavaScript via Name -


i'm working on making timer application, @ moment, have timers set default values, 5:00, until image above clicked. code clicking image this:

<a href="#" onclick="timer1()"><img src="images/icons/image.png" id="id"></a> 

when clicked, want adjust following span code:

<span id="timer" class="one" name="blue1">5:00</span> 

however, there many parts code , css styles, can't spare id or class variables, i'd use javascript target timer 1 unshared name, name="blue1". here javascript now.

function bluetimer1() {  document.getelementsbyname('blue1').innerhtml="blah";  } 

obviously do once done it, need able modify text within span, don't care edits to.

thanks assistance.

actually document.getelementsbyname('blue1') return collection/array object of spans there 1 need select first 1 using:

document.getelementsbyname('blue1')[0].innerhtml="blah"; 

so it'll work, if use getelementbyid('timer') can usong:

document.getelementbyid('timer').innerhtml="blah"; 

make sure have 1 element using 1 id, means id must unique.


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -