TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-03-2009, 05:20 AM   #1 (permalink)
The Wanderer
 
superthin's Avatar
 
Join Date: Aug 2008
Posts: 16
Thanks: 7
superthin is on a distinguished road
Default Could I get a href properties with javascript?

Hello Everybody,

I have a link:

Code:
<a href="myotherlink.html" onclick="myfunc();">Link to edit page</a>
I want to when I click "Link to edit page" a javascript function myfunc() will be executive (alert Link to edit page as example"). In other way, I want to get value / properties extract from a a href:

Ex: I want to get myotherlink.html and its GUI / its text "Link to edit page" value with JavaScript.

Could I do that?

Thanks a lot.
__________________
http://khoancatbetong.com - Vietnamese Concrete Technician Forum
superthin is offline  
Reply With Quote
Old 08-03-2009, 07:03 AM   #2 (permalink)
The Acquainted
 
JaoudeStudios's Avatar
 
Join Date: Jul 2009
Location: Surrey
Posts: 105
Thanks: 1
JaoudeStudios is on a distinguished road
Default

Using jQuery...

var href = $(this).attr('href');
var text = $(this).text(); // or html(), I cant remember
__________________
JaoudeStudios.com | JaoudeStudios.com Forum | JaoudeStudios.com Blog
OpenSource is the road ahead...!
JaoudeStudios is offline  
Reply With Quote
Old 08-03-2009, 01:19 PM   #3 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,267
Thanks: 90
Wildhoney is on a distinguished road
Default

You have innerHTML and getAttribute('href') without using jQuery. As long as you have the a node then those will be accessible.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Easily Format JSON using PHP and Interpret using Javascript Wildhoney Advanced PHP Programming 9 06-22-2009 01:12 AM
javascript question allworknoplay Javascript, AJAX, E4X 15 04-23-2009 09:30 AM
If no javascript?? delayedinsanity Javascript, AJAX, E4X 23 06-13-2008 05:06 PM
Part 1: Getting Started with Javascript and DOM Wildhoney Javascript, AJAX, E4X 6 11-08-2007 11:52 AM
Preventing Spam with PHP and Javascript Wildhoney General 9 10-24-2007 11:35 AM


All times are GMT. The time now is 11:33 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design