Scottus wrote:
> thanks you answer didn't exactly answer my question but it got me thinking
> in the correct way. IE i needed to reload the script AFTER the new
> html/dom is added. So I put script tag and fuctions at the bottom of
> the page i was loading into the div. And it was all good.
>
Scottus,
Wrap the the click assignment in $().ready(function() { .... }); like
I said && it doesn't matter where you put it!
~ Brice
> On 2/27/07, Brice Burgess <[EMAIL PROTECTED]> wrote:
>
>> Scottus wrote:
>>
>>> Now I have a script in the header,
>>>
>>>
>>> $("div#newcode").click(function(){alert('this works');});
>>>
>>>
>> Scottus;
>>
>> For starters; There is never a need to use to scope a selector when
>> selecting by the ID. All it does is decrease performance of the
>> selector. E.g. $("div#newcode")... should be $("#newcode").
>>
>> Besides that, your function looks fine. I presume that it is not firing
>> becuase it is executing before the DOM is ready and div#newcode
>> available to assign the click event to. Most jQuery code is encased in
>> the $(document).ready() function, which is a 100000 times more flexible
>> & accurate than window.onload. So use;
>>
>> $().ready(function() {
>> $("#newcode").click(function(){alert('this works');});
>> });
>>
>> in the header.
>>
>> Hope this helps,
>>
>> ~ Brice
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/