|
|||
|
HI,
I have a HyperLink in my code. It has a OnClick function defined. I am trying to access the text property of the HyperLink in my JavaScript function. <CoreCtrl:Controls.WebControls.HyperLink id="securityCodeLink" text="My Text" OnClick="ShowText(this);" Href="#" CssClass="textSmall" runat="server" /> function ShowText(obj) { alert(obj.text); } I also tried getting a var for the hyperlink with its id and showing its text. It says 'undefined' instead of 'My Text'. Am I doing something wrong? Thanks, Avanti |
|
|
||||
|
||||
|
|
|
|||
|
avanti wrote:
> function ShowText(obj) > { > alert(obj.text); > } > > I also tried getting a var for the hyperlink with its id and showing > its text. It says 'undefined' instead of 'My Text'. Am I doing > something wrong? There is no default property called "text" for anchor elements. You should use innerHTML as follows: function ShowText(obj) { alert(obj.innerHTML); } |
|
|||
|
Avanti,
You can determine the text attribute value in this manner: <a href="#" text="sometext should go here" onClick="alert(this.getAttribute('text'))" > Show the Text Attribute Value </a> Hope that helps, Jim |
|
|||
|
Thanks guys for the quick reply. It worked!
Jim wrote: > Avanti, > You can determine the text attribute value in this manner: > <a href="#" > text="sometext should go here" > onClick="alert(this.getAttribute('text'))" > > > Show the Text Attribute Value > </a> > > Hope that helps, > > Jim |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Re: Heiracical Parsing Exercise | Arthur Tabachneck | Newsgroup comp.soft-sys.sas | 0 | 05-09-2006 03:18 AM |
| Re: Heiracical Parsing Exercise | Jiann-Shiun Huang | Newsgroup comp.soft-sys.sas | 0 | 05-08-2006 11:42 PM |
| Heiracical Parsing Exercise | Michael Murff | Newsgroup comp.soft-sys.sas | 0 | 05-08-2006 10:49 PM |
| Re: SAS/AF: Validate Text Entry Control after user leaves field | Randy Herbison | Newsgroup comp.soft-sys.sas | 0 | 12-16-2005 10:55 PM |
| LayPerson's-Macro 101: Re: Passing by reference | Terjeson, Mark | Newsgroup comp.soft-sys.sas | 0 | 12-13-2005 04:33 PM |