[Nitro] JQuery questions

Jonas Pfenniger zimba.tm at gmail.com
Thu Nov 2 14:38:37 EST 2006


On 02/11/06, George Moschovitis <george.moschovitis at gmail.com> wrote:
> I have a jquery question. Is it possible to emulate (programmatically
> force) a click on a button from the even handler of another button? Ie
> something like:
>
> $('#srcbutton').click(function() {
>   $('#targetbutton').force_click();
> });

Hi George,

Go to http://www.visualjquery.com/index.xml  , Events -> Mouse -> click()
Last time I've tried (v1.0.2) this didn't work but now it may. I
suspect it now working like you want if you're using the event object
in the callback function. So your code should look like that :

$('#srcbutton').click(function() {
   $('#targetbutton').click();
});

If it doesn't work, here is what I usually do :

var do_something = function() { alert('this is the element's callback') }
$('#targetbutton').click(do_something)
$('#srcbutton').click(do_something}

-- 
Cheers,
  zimbatm

http://zimbatm.oree.ch


More information about the Nitro-general mailing list