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 8314971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:00:08+00:00 2026-06-08T21:00:08+00:00

JQuery + HTML + CSS I am trying to get the links on a

  • 0

JQuery + HTML + CSS

I am trying to get the links on a nav bar to update a “div” tag that I have. I got that to work, but I have to click each hyperlink twice before it loads the page on the main viewer. Why? How do I make it load after only one click?

test.js:

function onScreen(id){
    $("a#" + id).click(function(){$("div#viewer").load(id + '.html')});  
}

main.html:

<a href="#" id="about" onclick="onScreen('about')">About Us</a>
<a href="#" id="account" onclick="onScreen('account')">My Account</a>

etc.

<div class ="article" id="viewer">
    <p>welcome to this awesome site! </div>

There is an “about.html” file (and all other necessary files) in the same folder. Again, the code functions, just not as it is supposed to.

  • 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-06-08T21:00:10+00:00Added an answer on June 8, 2026 at 9:00 pm

    The first click execute onScreen, which associate the load function to the click event.
    The load function is thus triggered the second time you click.

    Edit

    A solution could be to remove the onclick attributes on your <a href=#> tags

    $(function(){
        $("a[href='#']").click(function(){$("div#viewer").load(this.id + '.html')});
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get two jQuery slides to work in a HTML page.
I have been learning css & jquery. <!DOCTYPE html> <html> <head> <style type=text/css> #box
well I have been trying to get Nivo Slider to work almost all day.
I'm trying to create a fade in effect using jQuery, html & CSS with
I'm trying to get jQueryMobile working using that latest Alpha release (3) and jQuery
Trying to get menu header with active color when submenu is opened CSS: #main-nav,
I am trying to get the following code to work so that the list
I have been trying to get this code to work for a while now
I have a div in my html called logo and what I am trying
I have a list of links, that I've made a 'popup' div for, on

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.