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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:30:15+00:00 2026-05-29T19:30:15+00:00

Can anybody give me the syntax on how could I determine where the onclick

  • 0

Can anybody give me the syntax on how could I determine where the onclick event was called.

I want to change the h4 content depending on where the onclick came from

For example:

  • if label() is called in "woven badges" , h4 innerhtml will be "woven badges"
  • if label() is called in "woven tapes" , h4 innerhtml will be "woven tapes"

I want to incorporate this into just one function and not to actually create one function per category which I’m currently doing with my JavaScript below. How can create it into if conditions?

function label()
{   document.getElementsByTagName("h4")[0].innerHTML="badges";}


<ul class="overview">

<li><img src="images/UniwinNav.jpg" align="texttop"/><a href=""><div class="listlabel">Woven Labels</div></a></li>

<li><img src="images/UniwinNav.jpg" align="texttop"/><a href="#" onClick='label()'><div class="listlabel">Woven Badges</div></a></li>

<li><img src="images/UniwinNav.jpg" align="texttop"/><a href=""><div class="listlabel">Woven Tapes</div></a></li>
<li><img src="images/UniwinNav.jpg" align="texttop"/><a href=""><div class="listlabel">Woven WaistBands</div></a></li>


<h4>Product Specification</h4>

</ul>
  • 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-29T19:30:16+00:00Added an answer on May 29, 2026 at 7:30 pm

    Just pass this as an argument to the label() function. It is a reference to the element that initiated the event. You can then easily find the string you want by grabbing the inner HTML of the first child element.

    <script type="text/javascript">
    function label(element) {
        document.getElementsByTagName("h4")[0].innerHTML=element.firstChild.innerHTML;
        return false;
    }
    </script>
    
    <ul class="overview">
    
    <li><img src="images/UniwinNav.jpg" align="texttop" /><a href="#" onclick="return label(this)"><div class="listlabel">Woven Labels</div></a></li>
    <li><img src="images/UniwinNav.jpg" align="texttop" /><a href="#" onclick="return label(this)"><div class="listlabel">Woven Badges</div></a></li>
    <li><img src="images/UniwinNav.jpg" align="texttop" /><a href="#" onclick="return label(this)"><div class="listlabel">Woven Tapes</div></a></li>
    <li><img src="images/UniwinNav.jpg" align="texttop" /><a href="#" onclick="return label(this)"><div class="listlabel">Woven WaistBands</div></a></li>
    
    <h4>Product Specification</h4>
    

    Note that it is a good idea to add a return value to the label() function and return it when the element is clicked. This will cancel the default browser action, meaning you don’t get that pesky # character in your location.

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

Sidebar

Related Questions

Can anybody give me a direction, I want to know how to do auto
can anybody give me links to dowlnload libmp3lame.so file.I want to convert mp3 stream
Can anybody give me any hints on that? I'm able to display xml content
I want to design the following UI. Can anybody give me an example or
Can anybody give me a simple TDI driver which can block traffic from specified
Can anybody give any working example of how to read/write Unicode text files using
Can anybody give me a little advice please? I have a string, for example
Can anybody give me an example how to use the osgi framework classes? I
Can anybody give a link for a simple explanation on BFS and DFS with
Can anybody give an example of c++ code that can easily convert a decimal

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.