JQuery: Why Unobtrusive JavaScript / Document Ready function rather than OnClick event?

前端 未结 4 916
别那么骄傲
别那么骄傲 2020-12-15 01:26

I\'ve just started looking at JQuery. I don\'t have any AJAX in my web application at present.

My existing JavaScript in my HTML looks like:

4条回答
  •  太阳男子
    2020-12-15 01:58

    Over time I think you get used to the jQuery syntax and reading:

    class="MyFormSubmit" becomes as informative as reading onClick="return MyFormSubmit();

    Where the power really starts to kick in (aside from all the benefits mentioned by other posters) is the ease with which you could change the onClick binding via selectors tied to other actions on the web page in ways that never seem to present themselves initially.

    One question I ask myself is how deep I plan on going with any new tool, if I am planning to make extensive use of a framework or library then writing my code in it's "more native" coding style will become a lot more natural and other developers that know the tool will find the code a lot cleaner and more understandable.

提交回复
热议问题