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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:58:42+00:00 2026-05-26T15:58:42+00:00

I am trying to create a button on an <a href=# …> tag using

  • 0

I am trying to create a button on an <a href="#" ...> tag using HTML+CSS+Javascript+jQuery. The button displays properly. However, when I click on it nothing happens except for the default behavior (i.e., navigating to “#”) . Any suggestions of what I am doing wrong? Here is my code:

    //container is a div created with 
    //borderDiv = document.createElement('div') and 
    //document.body.appendChild(borderDiv);

function addMenuNavigation(container) {
    var temp_innerHTML = '' +  
    '<div id="titleBar" class="titleBar">' +

    '<div id="menuTitle" class="menuTitle"><img id="titleImage" style="height: 70px; position: absolute; top: 2px; left:120px"></img></div>' +

    '<a href="#" class="leftButton" id="leftButton">' + 
    '   <div style="position: relative; top: 6px;"><img src="' + getURL('img/menu/iPhoneStyle/chevronLeft.png') + '"></img></div>' +
    '</a>' +

    '</div>' + //titleBar
    '';

    container.innerHTML = temp_innerHTML;

    var $leftButton = $('#leftButton');
    console.dir($leftButton); //Indeed it does display the #leftButton element


    //FIXME BUG 'MenuNavigation' below functions do not get registered ...

    $('#leftButton').mousedown(function(e) {
        $('#leftButton').addClass("pressed");
        console.log('leftButton down ' + this.id);
    });
    $('#leftButton').mouseup(function(e) {
        console.log('leftButton up ' + this.id);
        $(this).removeClass("pressed");
    });
    $('#leftButton').click(function(e){
        console.log('leftButton clicked ' + this.id);
        click_e.preventDefault();
    });

}

.css is as follows

.titleBar {
    ...
    display: block;
    height: 63px;
    opacity: 0.8;
    padding: 6px 0;
    ...           
    background-image: -webkit-gradient(linear, left top, left bottom, 
                                       from(#bbb), to(#444));                                                                    


    z-index: 35;                       
}


.leftButton:not(ac_hidden), .leftButton:not(pressed) {
    left: 6px;
    ...
    -webkit-border-image: url(../img/menu/iPhoneStyle/back_button.png) 0 8 0 8;
}


.leftButton.pressed{
    -webkit-border-image: url(../img/menu/iPhoneStyle/back_button_clicked.png) 0 8 0 8;
}

I am working with Chrome.

Any suggestions? Thank you.

  • 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-26T15:58:43+00:00Added an answer on May 26, 2026 at 3:58 pm

    Could it be that the browser hasn’t finished adding your HTML to the DOM yet before you try to attach an event to it?

    i.e, between these two lines?

    container.innerHTML = temp_innerHTML;
    
    var $leftButton = $('#leftButton');
    

    In which case, perhaps you want to attach the events with .live(), http://api.jquery.com/live/

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

Sidebar

Related Questions

I am trying to create a button using CSS Gradients plus a icon that
I am trying to create a button using jquery. I use the following code
i am trying to create a Radio button using Cakephp like the one the
I'm trying to create a button with icon like this : HTML: <div id='button'>
I am trying to create a text button using simple span and formatting the
Using Silverlight 4 & WPF 4, I'm trying to create a button style that
Using Visual C# 2008 express edition, I am trying to create a button on
I am trying to create a button called SignIn that accommodates browsers without javascript,
I'm trying to create a button with a rectangle since we're gonna have different
I'm trying to create a custom button where the foreColor is always crimson and

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.