•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 456,485 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,786 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 2240 | Replies: 1
![]() |
•
•
Join Date: Sep 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Hello,
I have a link that carrys out a DHTML function within my page, and once this link is clicked, i use the following js to change the text of the link.
In an external js file
The link
So, once clicked, the text changes from Click here!, to This text has changed!. But i want to be able to revert to the original text, once the link is clicked again.
An example is http://demo.rockettheme.com/apr07/ The top panel 'Open Control Panel' changes and then reverts the link text on subsequent clicks.
Any help please?
I have a link that carrys out a DHTML function within my page, and once this link is clicked, i use the following js to change the text of the link.
In an external js file
function exp(obj) {
var el = document.getElementById(obj);
el.innerHTML = 'This text has changed!';
}The link
<a name="a" href="javascript:exp('a');">Click here!</a>So, once clicked, the text changes from Click here!, to This text has changed!. But i want to be able to revert to the original text, once the link is clicked again.
An example is http://demo.rockettheme.com/apr07/ The top panel 'Open Control Panel' changes and then reverts the link text on subsequent clicks.
Any help please?
•
•
Join Date: May 2005
Location: Wellington, New Zealand
Posts: 182
Reputation:
Rep Power: 4
Solved Threads: 3
Hi,
If you want to do this with a lot of different links and for it to work well in IE and Firefox, then you might want to change it a little... alternatively, I would use an ID attribute instead of a name... Anyhow, take a look at this:
If you want to do this with a lot of different links and for it to work well in IE and Firefox, then you might want to change it a little... alternatively, I would use an ID attribute instead of a name... Anyhow, take a look at this:
<html>
<script type="text/javascript">
function exp(obj) {
if(obj.oldText){
obj.innerHTML = obj.oldText;
obj.oldText = null;
} else {
obj.oldText = obj.innerHTML;
obj.innerHTML = 'This text has changed!';
}
}
</script>
<body>
<a href="#" onclick="javascript:exp(this);">Click here 1!</a><br/>
<a href="#" onclick="javascript:exp(this);">Click here 2!</a><br/>
</body>
</html>![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Link Popularity (Search Engine Optimization)
- Random image with text and link (JavaScript / DHTML / AJAX)
- Open In New Window Php (PHP)
- link text boxes with listbox (VB.NET)
- Getting rid off the border round link images (HTML and CSS)
- I have a link exchange on my site (Relevant Link Exchanges)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: "Must visit from" javascript wont work in IE...
- Next Thread: Showing Chat Msgs without reloading


Linear Mode