www.webdeveloper.com
Results 1 to 5 of 5

Thread: click one url hidden the other url

  1. #1
    Join Date
    Apr 2011
    Posts
    36

    click one url hidden the other url

    I have two url
    <td><a href="">like</a><a style="display: none">Unlike</a>
    is that possible I can switch click and switch hidden, if I click like the unlike show, if I click unlike the like show

  2. #2
    Join Date
    Jun 2007
    Location
    Winnipeg, MB CANADA
    Posts
    128
    two ways to do it:

    1. Using the code similar to what you have:
    PHP Code:
    <a href="#" onclick="this.nextSibling.style.display='inline'; this.style.display='none'; return false;" >like</a><a href="#" onclick="this.previousSibling.style.display='inline'; this.style.display='none'; return false;" style="display:none;">unlike</a
    but you have to keep the element together like that all the time.

    2. Using a single element, cleaner and less prone to failure:
    PHP Code:
    <a href="#" onclick="(this.innerHTML=='like')? this.innerHTML='unlike' : this.innerHTML='like'; return false;" >like</a

  3. #3
    Join Date
    Apr 2011
    Posts
    36
    Thank you for the reply, but how can I get the value that I click

  4. #4
    Join Date
    Jun 2007
    Location
    Winnipeg, MB CANADA
    Posts
    128
    Code:
    <a href="#" onclick="(this.innerHTML=='like')? this.innerHTML='unlike' : this.innerHTML='like'; alert(this.innerHTML); return false;" >like</a>
    you can replace the "alert" with whatever function you'd like to handle it.

  5. #5
    Join Date
    Apr 2011
    Posts
    36
    I need this value insert into to db, I still don't get how to get the value of my click
    Thank you!

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