---
title: "Jquery event function trigger once despite of multiple time attach"  
description: "Jquery event function trigger once despite of multiple time attach"  
author: "Anonymous User"  
published: 2013-05-02  
updated: 2013-05-02  
canonical: https://www.mindstick.com/forum/791/jquery-event-function-trigger-once-despite-of-multiple-time-attach  
category: "jquery"  
tags: ["jquery"]  
reading_time: 1 minute  

---

# Jquery event function trigger once despite of multiple time attach

Hi [Expert](https://www.mindstick.com/articles/13120/an-expert-financial-advice-will-improve-your-finances)!\
How can i do this\
html\
<[button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) id="onclickpopupmenu">Test</button> <button id="popupmenuok"></button>[javascript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript):\
$("#onclickpopupmenu").bind("click",[function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server)(){\
alert("this can [execute](https://www.mindstick.com/interview/49/how-can-i-execute-a-php-script-using-command-line) [multiple](https://www.mindstick.com/blog/12797/iowa-is-expected-to-see-heavy-growth-in-multiple-sectors) times") $("#popmenuok").bind("click",function(){ alert("this has to be triggered only once eventhough the [parent](https://www.mindstick.com/blog/154/how-to-find-parent-of-control-in-wpf) [event](https://www.mindstick.com/articles/167719/marquee-hire-benefits-of-event-lighting-hire-london) [trigger](https://www.mindstick.com/blog/167/triggers-in-wpf) multiple times") })})\
Please help me...\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)! \

## Replies

### Reply by AVADHESH PATEL

Hi Jeet!\
\
Only bind the handler once:\
\

```
var popupmenuBound = false;$("#onclickpopupmenu").bind("click",function(){  alert("this can execute multiple times");  if (!popupmenuBound) {    $("#popupmenuok").bind("click",function(){      alert("this has to be triggered only once eventhough the parent event trigger multiple times");    });    popupmenuBound = true;  }});
```


---

Original Source: https://www.mindstick.com/forum/791/jquery-event-function-trigger-once-despite-of-multiple-time-attach

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
