This is a discussion on "changing function once clicked" within the JavaScript Forum section. This forum, and the thread "changing function once clicked are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
changing function once clicked
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
||||
|
Okay, say I have a header:
<h1 class="header" id="myHeader" onclick="myfunction()">header</h1> that calls this function: function myFunction() { var x=document.getElementById("remove_div"); x.parentNode.removeChild(x); } Is there a way to change the header to this: <h1 class="header" id="myHeader" onclick="myfunction2()">header</h1> after it's been clicked? Thanks guys, I only just learnt javascript so bare with me
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|
|
|||
|
Re: changing function once clicked
RE you trying to remove the div onclick and then replace it when it's clicked again? There is probably an easier way to do this.
Pete. |
|
||||
|
Re: changing function once clicked
yeah
either method will do i guess How do you do that one?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Last edited by alexgeek; Aug 23rd, 2007 at 04:11. |
|
|||
|
Re: changing function once clicked
if you add a third function and a variable to test wheather you clicked on the headr, then you wont have to change any html.
like this:
|
|
||||
|
Re: changing function once clicked
thank for that
also, since: var x=document.getElementById("remove_div"); x.parentNode.removeChild(x); removes the div how to i put it back in? I don't want to use visiblity, as it just hides it and the space is still taken up
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
||||
|
Re: changing function once clicked
uh bump?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: changing function once clicked
If you change it too display none it actually takes it out of the document flow so that would be your best bet. You don't really want to be removing and re-writing the div into the code, that wouldn't be very efficient. You can either change the style attribute of that element or change the class name (you would have to have the alternative style set up in the css of course).
Hope that helps a bit. Pete. |
|
||||
|
Re: changing function once clicked
Thanks pete
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
![]() |
| Tags |
| function |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] Image links disappear after clicked | finalfantasyfanatic | Web Page Design | 14 | Dec 5th, 2007 12:14 |
| Jump to a new frame when clicked | rexusdiablos | Flash & Multimedia Forum | 8 | Jul 31st, 2007 18:02 |
| Check if user has clicked an adwords ad. | Kimochi | JavaScript Forum | 4 | Mar 4th, 2007 16:31 |
| submit button changes when clicked | troublesomegirl | JavaScript Forum | 0 | Feb 18th, 2007 01:10 |
| Making a rollover stick when clicked | map4202003 | Web Page Design | 4 | Apr 7th, 2004 07:26 |