JQuery - Best way of wiring GUI objects to events?

前端 未结 4 1097
长情又很酷
长情又很酷 2020-12-19 22:35

Ever since JQuery came along a few years ago I\'ve been using it in all my client-side scripts. Initially I used the \'$() syntax to grab and manipulate objects this, to me,

4条回答
  •  感动是毒
    2020-12-19 23:16

    The 'jQuery' way enforces the separation between content and functionality, which is a Good Thing IMO. It reduces the 'noise' in your content/markup. It also enables a programmer to concentrate on the scripting, whilst a 'marker-upper' concentrates on the HTML.

    BTW, you don't have to be 'overly-bracey', or use anonymous functions if you don't want to:

    function myFunction(obj){
        alert('this is a compromise!')
    }
    
    $(function() {
        $("#myButton").click(myFunction);
    });
    

提交回复
热议问题