Hi All:

I've read over the docs, but don't quite understand what the bind() event
provides versus just assigning a particular event handler to a selected
element (or set of elements).

For example, consider the code below.  What's the difference between the
interaction with the <p> elements of class "first", and the <p> elements of
class "second"?  Isn't the second bit effectively binding a click event
handler to a specific batch of "p" elements just as the first one is?

Just not grokking it.  Would appreciate if anybody could enlighten me.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js
"></script>

<script type="text/javascript">
    $(document).ready(function() {
        $('p.first').bind('click', function() {
            alert($(this).text());
        });

        $('p.second').click(function() {
            alert($(this).text());
        });
    });
</script>

<p class="first">A</p>
<p class="first">B</p>
<p class="first">C</p>
<p class="first">D</p>
<p class="first">E</p>

<hr />

<p class="second">F</p>
<p class="second">G</p>
<p class="second">H</p>
<p class="second">I</p>
<p class="second">J</p>

-- 
Charlie Griefer
http://charlie.griefer.com/

I have failed as much as I have succeeded. But I love my life. I love my
wife. And I wish you my kind of success.

Reply via email to