What is the difference between clicking a checkbox and calling its '.click()' function?

Consider the following code:

HTML:


Click here

JS:

$(function() {
    $('input').click(function() {
        document.write($(this).is(':checked') ? "checked" : "unckecked");
    });
    $('div').click(function() {
        $('input').click();
    });
});

When the checkbox is clicked, the output is checked, but if "Click here" is clicked the output is unckecked. Why is that?

10
задан CMS 17 September 2010 в 04:03
поделиться