Home >Web Front-end >JS Tutorial >What are the common methods of jquery

What are the common methods of jquery

藏色散人
藏色散人Original
2020-12-03 09:05:208929browse

Commonly used methods of jquery are: 1. ".bind()" method; 2. ".unbind()" method; 3. ".css()" method; 4. ".hasclass()" Method; 5. ".removeclass" method; 6. ".parent()" method, etc.

What are the common methods of jquery

Recommended: "jquery Video Tutorial"

Several jQuery Commonly used methods

.bind()

.unbind()

.css()

.hasclass()

.removeclass

.parent()

.children()

.html()

.hide()

.show()

.attr()

.val()

##The three most commonly used methods of jQuery AJAX

<script>
    //把所有需要用到的地址归类到一个对象里
    var webUrl = {
        "show1Url": "{{ url(&#39;address/list1&#39;) }}",
        "show2Url": "{{ url(&#39;address/list2&#39;) }}",
        "show3Url": "{{ url(&#39;address/list3&#39;) }}"
    };

    // get方式
    function getData() {
        $.get(webUrl.show1Url,  //获取地址
            function(json){
                console.log(json);
             });
    }

    // post方式
    function postData(v1) {
        $.ajaxSettings.async = true;   //在这里设置同步或异步 默认为true(可不写)  false为同步

        $.post(webUrl.show2Url,   //获取地址
            {
                "id":v1          //需要传输的数据
            },
            function(json){
                console.log(json);
            });
    }

    // ajax方式
    function fullData(id) {
        $.ajax({              //  AJAX 请求设置。所有选项都是可选的。
            async:false,        //请求是同步或异步    默认为true  为true时不用写
            type: "POST",            //设置类型
            url: webUrl.show3Url,           //数据传输地址
            dataType: "json",               //获取的数据类型
            data: {"id":id},            //传参
            success: function (json) {      //请求成功之后调用
                // console.log(json);
                console.log(json);
            },
            error: function () {        //请求出错时调用
                console.log("请求失败");
            }
        })
    }

</script>

           

The above is the detailed content of What are the common methods of jquery. For more information, please follow other related articles on the PHP Chinese website!

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