Home >Web Front-end >JS Tutorial >The application of windows.onload in Jqyery is equivalent to that of windows.onload in js_jquery

The application of windows.onload in Jqyery is equivalent to that of windows.onload in js_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 18:06:521049browse
Copy code The code is as follows:

$(function(){//script})
Jquery (function(){//script})
Jquery(document).ready(function(){//script})

The above three codes perform the same action, which is convenient to write , so Jquery is more popular than other applications, but when used with other js libraries, especially when prototype.js is used at the same time, the $ method cannot be used because they also have this method. You can use the following method to avoid this Conflict:

jQuery(function($){//script})

They are all operations performed after the Dom is loaded, so they can be placed anywhere in the html, but some For example, the loading event method mentioned in the previous section
Copy the code The code is as follows:

Hello,Word!




< script type="text/javascript">
$("#btnShow").bind("click",function(event){$("#divInfo").show()});
$ ("#btnHid").bind("click",function(event){$("#divInfo").hide();});
$("#btnChange").bind("click", function(event){$("#divInfo").html("hello");});


This is executed during the loading process Yes, the relevant elements must be loaded before they can be executed. It will be much more flexible if you put them into the above code
Copy code The code is as follows:

Hello,Word!






Then this loading event can be placed anywhere...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn