jquery use

Use of jquery:

1. jquery注册事件:$("#btn").click(function (){ $(this).css(“backgroundColor”,“red”)})

2.jquery converts dom objects: $("bthObj").get(0) or $("btnObj")[0]

3. dom object to jquery: $(btnObj)

4.dom获取:document.getElementById("btn")...

5.jquery get: $("#btn")

6.js set the style: this.style.backgroundColor="red"

7. Methods in jquery: The .val() method gets the value. .text() gets the text value. .html() gets the content of the element displayed in the div.

Generally, writing content in the method is to set the content to the element, and writing nothing is to get the content.

8. Mouse over and leave event: $("#uu>li").mouseover(function (){ $(this).css("backgroundColor","red")})

                                   $("#uu>li").mouseout(function (){ $(this).css("backgroundColor","")})

9. Get all child elements children: $(this).children("ul").show();

10. Index selector: eq(3) judges that the index is equal to 3. lt(3) determines if the index is less than 3. gt(3) determines if the index is greater than 3.

11. Get the current index value: var index=$(this).index

   The following generally deal with the problem of tab bar switching as follows:

    Judging equal: $("#center>li:eq('+index+')").siblings("li").hide();

                         $("#center>li:eq('+index+')").show();

12. The .find() method finds some other elements inside the current element.

 To deal with the drop-down menu display hidden problem:

       $(this).children("ul").find("li").show();

       $(this).siblings("li").find("ul").find("li").hide();

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324851214&siteId=291194637