www.webdeveloper.com
Results 1 to 3 of 3

Thread: How to make a <a href> link disappear

  1. #1
    Join Date
    May 2012
    Posts
    37

    How to make a <a href> link disappear

    Hi,
    I have a <a href> in my code which is as follows


    Code:
    <a href="javascript:editPage();">[Edit mode]<br></a>
    My requirement is , when I click on that link [Edit mode] it will not be visible anymore. But ofcourse the javascript function editPage() will get successfully
    executed so that my purpose is served.

    Currently the problem is after clicking that link, the function is executed successfully but the link does not disappear.

    Please help. Thanks.

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,252

    Lightbulb

    Something like this?
    Code:
    <!DOC HTML>
    <html>
    <head>
    <title> Untitled </title>
    <script type="text/javascript">
    function editPage() {
      document.getElementById('TArea').readOnly = false;
      document.getElementById('pgEdit').style.display = 'none';
      document.getElementById('pgView').style.display = '';
    }
    function viewPage() {
      document.getElementById('TArea').readOnly = true;
      document.getElementById('pgEdit').style.display = '';
      document.getElementById('pgView').style.display = 'none';
    }
    </script>
    
    </head>
    <body>
    <a href="" id="pgEdit" onclick="editPage();return false;">[Edit mode]</a>
    <a href="" id="pgView" onclick="viewPage();return false" style="display:none">[View mode]</a><br>
    <textarea id="TArea" readOnly>Contents of text area.</textarea>
    </body>
    </html>

  3. #3
    Join Date
    Jan 2011
    Posts
    117
    here is your solution:
    PHP Code:
    <a href="javascript:editPage()" onclick=this.outerHTML="">[Edit mode]<br></a
    click it and the link will disappear as if it never existed.
    Last edited by Troy III; 10-10-2012 at 03:08 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles