Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7047731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:48:24+00:00 2026-05-28T02:48:24+00:00

I have the .live aspect working now so if links are clicked, my function

  • 0

I have the .live aspect working now so if links are clicked, my function is executed, but I’m trying to figure out how include an option for a direct link to the content as well. Something like this:

$(showDiv).is('shipping-timeline')
or
$("#inm_if_hc_shipping_timeline").live('click', function() {
  [code to show and hide divs]            
});

showDiv contains the value that identifies the proper id, extracted from the URL.

My Question: How do I construct the IF statement to execute if either case is true?

Can anyone help? Thanks!

UPDATE:

So I took the IF parts from Graydot’s answer and applied it to my code and here is a more complete example of what it looks like now:

$("#inm_if_hc_faq").bind('click', function(e) {
    if(showDiv == 'faq') {
            // prevent default behavior
            e.preventDefault();

            $("#inm_if_hc_content_faq").show("slow");   
            $("#inm_if_hc_content_shipping_timeline").hide("fast");
    }

        });

The most important part I was missing was having the default behavior and an IF that overrides it… thanks Graydot!

Now when the link is clicked, the div shows like it should, but not when the URL is entered.

Example: http://myurl.com/thispage.html?show=faq

I didn’t include the function that populates the variable showDiv here, but I have verified in the console that it contains ‘faq’ as it should.

Anyone see what I am still missing?

Thanks!

FINAL UPDATE: SOLUTION

I didn’t understand it at first, but the solution proved to be rethinking my approach. I appreciate that someone could see through my ignorance and came up with a great solution.

Here’s the working code example:

$(window).bind('hashchange', function () {
    var hval = location.hash.slice(1);

    if (hval == "faq") {
        $("#inm_if_hc_content_faq").show("slow");   
                    $("#inm_if_hc_content_shipping_timeline").hide("fast");
    }
});

$(document).ready(function() {

    $(window).trigger('hashchange');

});

With this, the link can be as simple as href=”#faq” or from another page href=”http://mydomain.com/mypage#faq”. No need to parse the URL for a variable or to use the IF statement to tell the difference between the nav link or an outside link.

Hope this helps someone else, so then I won’t have to feel so ignorant! 😉

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:48:24+00:00Added an answer on May 28, 2026 at 2:48 am

    Use a hashtag, perhaps? By binding to the “hashchange” event instead of the “click” event, you should be able to get the results you want.

    // run specific code based on the url hash
    $(window).bind('hashchange', function () {
        var hval = location.hash.slice(1);
        if (hval == "timeline") {
            // run whatever code or function you like
        }
    });
    
    // trigger it on page load
    $(document).ready(function () {  
        $(window).trigger('hashchange'); 
    

    }); 

      
    Now just make your clickable link look like

    <a href="#timeline">click me</a>
    

    and you have a clickable, bookmarkable JavaScript function. Whenever the URL hash changes, the hashchange event will be triggered instantly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a live click function that needs to do certian things always but
Until now, I was always working on my own for PHP-projects, but at the
I have a live() function in my jquery below: $(#qandatbl td.weight input).live(change, calculateTotal); function
I have a live function that triggers the 'openwindow' function and I need to
I have a live SQL Server 2008 database and I need to start working
I have created a simple app. Now I want to have a live wallpaper
Please imagine you have an live-application with used data in your doctrine-controlled database. Now
I have a script that does an update function live. I would move it
I'm working on a vision application and I need to have a Live View
I am loading content into a page with ajax that will have live click

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.