views:

33

answers:

1

Hi,

I have this code in my HTML document and I would life to bind click event on such elements.

<gui:button id="btnTest">
  <label>Compose mail</label>
  <click>someaction()</click>
</gui:button>

I tried this two methods in my document.ready function, but none of them work

$('gui\:button').click(function() { alert('clicked'); });
$('button').click(function() { alert('clicked'); });

Is there any other way to bind click event to such elements?

+4  A: 

Binding the event to the ID will be quickest:

$('#btnTest').click(function() { alert('clicked'); });
RyanP13
If the content is being dynamically injected into the page via AJAX then review the .live() or the .delegate() methods also.
RyanP13
I figured it out ... $('gui\\:button').click(function() { alert('clicked'); });
Mitja Felicijan