0

I have a hyperlink button and I don't know the click event function associated with it.

<div class="originalPlace"> // Original Element parent
    <a title="Create" class="QButton" style="visibility: visible;"><span class="k-sprite fa fa-plus"></span></a>
</div>
....
<div class="newPlace"></div> // Move here

However, I am trying to move this button to another position in the DOM using append and I would like to move its associated click event as well. Is there a way to know the current click event using jQuery, append to newPlace and then move the click event associated with it as well? Kindly let me know.

Cheers.

Neophile
  • 5,660
  • 14
  • 61
  • 107
  • Check this question: http://stackoverflow.com/questions/2518421/jquery-find-events-handlers-registered-with-an-object – Keammoort Dec 03 '15 at 12:39
  • 1
    It's likely that your click event is added by javascript (which you've not included in the question). Simply moving it in the **html** *should* have no effect, but it depends on how it is attached. I say **html** because changing it *before* it's rendered should have no effect, but changing it in the DOM (after the page has been served, ie via javascript) will likely break any existing event handlers (again, depending on how they have been added) – freedomn-m Dec 03 '15 at 12:39
  • use the existing parent element to catch the click event rather than adding click event handler on dynamic element added by javascript. – kailash yogeshwar Dec 03 '15 at 13:05
  • I agree, however is there a way to fetch the existing javascript code that is set on that element and then carry it across? I don't have any code myself as this is on a website that has already been built. – Neophile Dec 03 '15 at 13:44
  • Can we do a .clone(true) instead? This would clone the element with the events but wouldn't move it as such. I'll have to manually hide the original element. Is that a feasible option? – Neophile Dec 03 '15 at 13:49

0 Answers0