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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:22:20+00:00 2026-06-16T15:22:20+00:00

I have this code in my html page: <body> <div align=center> <a href=../index.html> <img

  • 0

I have this code in my html page:

    <body>
    <div align="center">
      <a href="../index.html">
      <img border="0" src="banner1.jpg" width="800" height="120" alt="Ecommerce Knowledge Base">    </a>

      <div style="background-image:url(Heading%20Background.jpg); width:800px">
      <a href="../index.html" style="position:relative; left:-130px">HOME</a>
      <a href="" style="position:relative; left:-65px" id="planning">PLANNING</a>   
    </div>
    ...
    ...
    ...
    </body>

The hyperlink HOME is linked to index.html page which is located in the root folder of the folder containg this html page. But nothing happens once clicking this hyperlink. Even the banner which is linked to the same page doesn’t work.

The strange thing is, both these hyperlinks were working fine before, till I made some “jquery” code changes in my page. But I’m not sure how the change is affecting this. Kindly help.
These are the code changes made from:

    <script> 
    $(document).ready(function(){
      $("#planning").click(function(e){
        $("#planning_panel").slideToggle("slow");
        e.preventDefault()
       });
     });
    </script>

to:

    <script> 
    $(document).ready(function() {
     $(document).on('click',function(e) {
  e.preventDefault();
   var $panel = $("#planning_panel");
   if (e.target.id === 'planning') {
     $panel.slideToggle('slow');
   } else {
     $panel.slideUp('slow');
   }

        });
      });
     </script>

Both the scripts are working fine, the only problem is as soon the changes were made the hyperlinks stopped working.

  • 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-16T15:22:22+00:00Added an answer on June 16, 2026 at 3:22 pm

    This new code:

    $(document).ready(function() {
      $(document).on('click',function(e) {
         e.preventDefault();
         // ...
       });
    });
    

    …tells the browser that when a click occurs that bubbles up to the document (as most clicks eventually do, unless you call stopPropagation from a handler deeper down), the browser should prevent the default action. The default action of a click on a link is to follow the link.

    The solution is to only call e.preventDefault(); when you want to prevent the action of the click. Here’s how I’d probably recast that code:

    $(document).ready(function() {
      $(document).on('click',function(e) {
        var $panel = $("#planning_panel");
        if ($(e.target).closest("#planning")[0]) {
          // Click is on the planning link, toggle the panel and prevent the default
          $panel.slideToggle('slow');
          e.preventDefault();
        } else {
          // Not on the planning link, slide the panel up
          $panel.slideUp('slow');
        }
      });
    });
    

    Live Example | Source (I’ve changed ../index.html to http://stackoverflow.com on the HOME link, but other than that the only change is the code)

    There we’re only preventing the default action of the click if it’s on the #planning link.

    Side note: I’ve used closest instead of checking e.target.id because it’s more robust. It’s not strictly necessary with your markup, but if you ever changed the markup slightly (adding a span or em or something), you’d need it, so it’s good for robustness.

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

Sidebar

Related Questions

I have an html page with a link like this: <a href=javascript:window.print()>Print QR code</a>
I have the following Javascript code add_num = { f: function(html, num) { alert(this.page);
OK i have this code HTML: <html> <head> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js> </script> <script type=text/javascript>
I have this html code <html> <head> <title>JQuery Problem 2</title> <script type=text/javascript src=jquery-1.4.min.js></script> <script
I have this HTML code: <div class='com_box'> <div class='com_box_c'> <div class='com_box_info'> <a id='quote'>quote</a> </div>
I have this HTML code: <div id=main> <div id=dv_7>...</div> <div id=dv_1>...</div> <div id=dv_8>...</div> <div
I have this HTML code which simulates a dropdown multi-checkbox <div> <div class=select> <span>Select
This is the code I have: <body> <form id=form1 runat=server> <div> <asp:TextBox ID=txtInsertComments CssClass=expanding
I have following HTML code: <div id=wrapper> <div class=page id=first> Test<br/> Test<br/> Test<br/> Test<br/>
So, I have this css code to format a html page. The problem is

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.