Javascript Show/Hide tweak

Posted on 2014-03-25
Last Modified: 2014-03-28
I have a simple javascript "show/hide" snippet I am using to show more content.

Use clicks "see more" and content drops down. He clicks "hide" and the content slides back up and away.

Problem is I would like to hide the "See more" once its clicked and show it again when "hide" is clicked.

Here is the Javascript:

<script type="text/javascript">

Open in new window

And here is the Div that is being shown/hidden:

<div class="slidingDiv">Content of showhide div</div>

Open in new window

and here are the two, identical show and hide links which obviously have the same basic affect:

<a href="#" class="show_hide">(see more)</a>

<a href="#" class="show_hide">(hide)</a>

Open in new window

Any thoughts on modifying this to hide the See More would be great
Question by:mcpilot1
  • 2
LVL 58

Accepted Solution

Gary earned 500 total points
ID: 39953771

<a href="#" class="show_hide">(see more)</a>
<div class="slidingDiv">Content of showhide div</div> 

Open in new window

        varText=($(this).text()=="(see more)")?"(hide)":"(see more)"

Open in new window


Author Comment

ID: 39961442

INterestingly, while it's working on your code site, it's not working on the actual site. I have replaced the script in the header, basically overwriting the original version that I posted and it's not working. The "See More" is not appearing at all, despite being vieeable in the source code.

It should be a jquery conflict because the original code worked, and this is but a minor variation of that. I have attached the entire source code as an attachment since this is a shopify file and it's nearly impossible to view the dev site.

LVL 58

Expert Comment

ID: 39961805
You have this in your css - stylesheet.css line 513

.show_hide {
    display: none;

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to change pointer icon to hand icon on mouseover 2 19
Bad <form> statement? 9 26
Not seen Link button 5 15
Google Sheets script efficiency 2 4
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now