Your Ad Here

Posted By

krisdb on 04/27/07


Tagged

javascript


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


toggleText


 / Published in: JavaScript
 

  1. function toggleText(id,text1,text2) {
  2. var DomObject = document.getElementById(id);
  3. DomObject.innerHTML = (DomObject.innerHTML == text1) ? text2 : text1;
  4. }
  5.  
  6.  
  7. <a href=""toggleText('Link_"&i&"','+','-');"" id=""Link_"&i&""">+</a>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: tigerlil on January 12, 2010

i've been looking at a lot of different styles of link toggles. but this one is so compact and clean.

I'm not an expert level javascript programmer though...so would someone explain the two sets of quotes after the href= ...? don't we normally write javascript:toggleText() etc?

Posted By: tigerlil on January 12, 2010

i've been looking at a lot of different styles of link toggles. but this one is so compact and clean.

I'm not an expert level javascript programmer though...so would someone explain the two sets of quotes after the href= ...? don't we normally write javascript:toggleText() etc?

You need to login to post a comment.