Here's an example that highlights the problem. Run this first sample
and note that the second button to appear does nothing when clicked:


<script type="text/javascript">
        $(function() {
                $("button").click(function() {
                        alert("ROOOOOOOOOOOOAR!");
                        $(this).after("<button>I've been loaded in from 
somewhere else, I
have no voice</button>");
                });
        });
</script>

<button>I'm in the page at the start, click me and hear me roar!</
button>


Now run this example. The only change being to use live() to bind the
click events:


<script type="text/javascript">
        $(function() {
                $("button").live("click", function() {
                        alert("ROOOOOOOOOOOOAR!");
                        $(this).after("<button>I'M ALIVE!!!!</button>");
                });
        });
</script>

<button>I'm in the page at the start, click me and hear me roar!</
button>


Any help?

On Jul 31, 6:54 am, solow <solow.wes...@gmail.com> wrote:
> Thanks a lot. This is the best answer av had so far.
>
> So as far as I understand, when calling for the page, where this
> javascript will be executed, I'll have to call for the functions
> again. so that it once again checks all ul li a tags?
>
> Because I've done some further reading, which brought me 
> tohttp://brandonaaron.net/and it says:
>
> "In jQuery 1.3.x, the .live() method binds its event handlers to the
> document."
>
> So, when using jQuery 1.3.x, I'll be able to say stuff like $
> ('div.jimgMenu ul li a').hover(function() {, but this would be...
> live, with the mouseover attribute right?
> Because I can't seem to get it working... Does someone maybe, have a
> small example for me. where I load in an external file, and use an
> alert onmouseover on a ul li a tag or something? Because I learn
> faster from code... Documentation always confuses me.
>
> Thank you so much.
>
> wesley.

Reply via email to