Home > Web Front-end > JS Tutorial > Why does jquery write entry functions?

Why does jquery write entry functions?

(*-*)浩
Release: 2019-05-30 11:43:43
Original
3079 people have browsed it

The role of the entry function, waiting for the page to be loaded, has an independent scope,

Why does jquery write entry functions?

jQuery entry function The writing method is as follows

<script>
        // 方式一
        $(document).ready(function () {
            alert("hello lnj");
        });        // 方式二,最常使用的一种
        $(function () {
            alert("hello lnj");
        });        // 方式三
        jQuery(document).ready(function () {
            alert("hello lnj");
        });        // 方式四
        jQuery(function () {
            alert("hello lnj");
        });
</script>
Copy after login

Example:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="jquery-1.7.1.js" type="text/javascript"></script>
</head>
<body style=" overflow-y:scroll;overflow-x:auto;">
<input type="text"  id="dd1" value="" />
<textarea id="tt" cols="30" rows="30"></textarea>
</body>
<script>
var i=1;
//jQuery方式

$(function(){
var str=$("#tt").val()+'\r\n'+'$_B加载完毕'+i;
$("#tt").val(str);
i++;
}) ;

</html>
Copy after login

The above is the detailed content of Why does jquery write entry functions?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template