You need to simply pass the name of the function without parentheses like so
$("#qSearchBut").click(quickSearch); Otherwise it executes the function immediately (upon parsing) and passes the result as an argument to .click(). - Richard On Fri, Nov 21, 2008 at 9:30 AM, .mini.moke <[EMAIL PROTECTED]>wrote: > > > Hi there, > > I'm pretty new to JQuery. I have a couple of elements that need to call > the > same function so my code looks like this: > > $("#qSearchBut").click(quickSearch()); > > Pretty simple I thought. But this call executes the quickSearch() function > on page load. What fundamental thing am I overlooking? > > Thanks in advance > > Amanda > -- > View this message in context: > http://www.nabble.com/NEWB-ALERT%3A-Why-when-calling-a-pre-existing-function-from-.click%28%29-is-it-executed-on-page-load--tp20622218s27240p20622218.html > Sent from the jQuery General Discussion mailing list archive at Nabble.com. > >