PDA

View Full Version : Trying to pass text node of THIS element into fn()


sethwb
11-04-2009, 08:52 PM
Hi:


<a href="#" onclick="showDistributors('city0','raccoon0','national0',pass link text as variable into the function "showDistributors"); alert(this.text()); return false;">St Albans</a>


How do I pass the distributor name into the function as a variable? I am having trouble finding useful information on "this" method

Epotus
11-04-2009, 10:22 PM
You can use

this.innerHTML


<a href="#" onclick="showDistributors('city0','raccoon0','national0',this.innerHTML); return false;">St Albans</a>

Kor
11-05-2009, 09:37 AM
Or you may use DOM references:

this.firstChild.nodeValue
or
this.firstChild.data