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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:35:41+00:00 2026-05-23T10:35:41+00:00

Using Google Closure Library : How can I handle clicking of an element for

  • 0

Using Google Closure Library:

How can I handle clicking of an element for example a div but prevent firing the event handler when the user clicks the child elements of that element.

For example in the following code I want to fire the event handler when user click div1 but when he/she clicks ‘span1’ I want another event handler to be called without firing the handler of div1.

<div style="width: 400px" id="div1">
 <span id="span1">click me to reload</span>
 click here to Toggle accordion
</div>

UPDATE

JS Code:

/**** accordion ***/
var panels = goog.dom.getElementsByClass('newsColumnHeader', goog.dom.getElement('accordionContainer'));

var anims  = {};
var open   = null;

goog.array.forEach(panels, function(pane){
  var animation = new goog.ui.AnimatedZippy(pane, goog.dom.getNextElementSibling(pane));
  goog.events.listen(animation, goog.ui.Zippy.Events.TOGGLE, zippyToggle);
  anims[goog.getUid(animation)] = animation;
});

function zippyToggle(event) {      
  var uid = goog.getUid(event.target);                  
  // simple logic - only one open panel in one time
  if (event.expanded && uid != open) {
    if (open) {
      anims[open].setExpanded(false);
    }
    open = uid;
  }
}
/******************/           

var refreshVarzesh3 = goog.dom.getElement("btnRefreshVarzesh3");
if (refreshVarzesh3 != null) {
  goog.events.listen(refreshVarzesh3, goog.events.EventType.CLICK, function(event) {
    /*doing something but not toggling accordion pane*/
  });
}

HTML CODE:

  <body>
<div class="main">
  <div class="top">
    <div id="toolbar">          
      <img src="css/img/contact.png" alt="تماس، پیشنهاد، گزارش خطا" title="تماس، پیشنهاد، گزارش خطا"/>          
    </div>
    <img src="css/img/football_news.gif" alt="آخرین اخبار فوتبال"/>
  </div>
  <div class="middle">
    <div class="left"></div>
    <div class="right">
      <div class="accordion" id="accordionContainer">
        <div class="newsColumnHeader">
          <div class="buttons">
            <img id="btnRefreshVarzesh3" src="css/img/refresh.png" alt="به روز رسانی" title="به روز رسانی"/>                
          </div>
          <%=lbls.getString("Varzesh3News")%>
        </div>
        <div class="newsList" id="varzesh3NewsContainer"></div>
        <div class="newsColumnHeader"><%=lbls.getString("PersepolisNews")%></div>
        <div class="newsList" id="persepolisNewsContainer"></div>
        <div class="newsColumnHeader"><%=lbls.getString("EsteghlalNews")%></div>
        <div class="newsList" id="esteghlalNewsContainer"></div>
        <div class="newsColumnHeader"><%=lbls.getString("NavadNews")%></div>
        <div class="newsList" id="navadNewsContainer"></div>
      </div>
    </div>
  </div>
  <div class="bottom"></div>
</div>

  • 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-23T10:35:41+00:00Added an answer on May 23, 2026 at 10:35 am

    for pure javascript developers the answer is here but if you use Google Closure Library the following code is enough:

    event.stopPropagation();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to minify a third-party JavaScript library using Google Closure Compiler, but
When using Google Chrome, I want to debug some JavaScript code. How can I
Currently using Google Analytics as a supplement to our paid tracking software, but neither
We are using Google Charts for render the chart images, but 500 requests/day became
I'm using Google closure to create a simple interactive graphic in HTML/JS to be
I'm using Clojure, but I can read Java, so this isn't a Clojure specific
This solution must use the google closure javascript library and not any other javascript
I'm using Google Closure Compiler application (command line interface). When I run it I
I'm getting a weird error using google closure compiler. I'm using externs to indicate
Using Google Chrome, if you console.log an object, it lets you inspect the element

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.