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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:40:12+00:00 2026-06-14T18:40:12+00:00

I have a simple bit of code (contained in a CMS and cant be

  • 0

I have a simple bit of code (contained in a CMS and cant be edited) that and needs to be read by Javascript in the header if it has been clicked.

Here is the code

<div id="example" class="page-element-outer" style="text-align: left">
    <div class="page-element-inner" >
        <input type="image" name="Button1" id="Button" src="/getresource.axd?AssetID=16813" alt="Submit" style="text-align:left;" />
    </div>
</div>

Can you assist?

  • 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-14T18:40:14+00:00Added an answer on June 14, 2026 at 6:40 pm

    You can select the element through its ID and attach a click-event listener using the addEventListener method.

    document.getElementById("Button").addEventListener("click", callback, true);
    
    function callback() {
       // Do some stuff in here when clicked
       alert("clicked");
    
       // Return false to prevent the browser default 
       // click-behaviour, if that is desired
       return false;
    }
    

    For legacy browsers

    Older versions of IE doesn’t support addEventListener, so for those you might need to do something like this:

    var el = document.getElementById("Button");
    if (el.addEventListener) {
      el.addEventListener('click', callback, false); 
    } else if (el.attachEvent)  {
      el.attachEvent('onclick', callback);
    }
    

    Wait for the DOM to be ready

    If you plan to run this in the head of your page, you’ll need to wrap it a DOM-ready event listener as well, otherwise there is a change that the click event isn’t attached to the element, as that element doesn’t exist in the DOM when your script is run.

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

Sidebar

Related Questions

I have a very simple bit of code that is supposed to capture the
I have a bit of sample code that is throwing this warning: main.c: In
simple bit of jquery. I have a div with clss linklist, inside it has
I have a pretty simple ASP.NET Web Form that looks a bit like the
I have been playing around a bit with a fairly simple, home-made search engine,
The code below plots some simple x-y data, but it has two problems that
I have code that creates an XML document that is difficult to read in
I have the following bit of code, simply: $(function() { $('a.add-photos-link').live('click', function(e) { $(this).colorbox({
I have a simple bit of jQuery which displays the row below the current
I have a very simple bit of jQuery to retrieve my latest Tweet $.getJSON(http://twitter.com/statuses/user_timeline/username.json?count=1,

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.