jQuery common methods

jQuery common method:

element display and hide:
if($("#test").is(":hidden")){
       $("#test").show(); //If the element is hidden, it will be shown
}else{
      $("#test").hide(); //If the element is visible, then hide it
}

Button disable and activate:
$("#btnSendCode").attr("disabled", "true") ; //Disable
$("#btnSendCode").removeAttr("disabled"); //Enable activation

js rendering page and fade effect:
appendTo('body').fadeIn(0)
Rendering fade

is added or changed by jQuery style
$(".spa").css("color","#BD362F")

jQuery manipulates CSS
jQuery has several methods for doing CSS manipulations
    addClass() - add one or more classes to the selected element
    removeClass() - remove one or more classes from the selected element
    toggleClass() - add to the selected element /Delete class toggle action
    css() - set or return style attribute
method:
return css attribute: $("p").css("background-color")
Set css properties: $("p").css("background-color","yellow")
Set multiple css properties: $("p").css({"background-color":"yellow"," font-size":"200%"})

Select HTML elements, and hide, move, manipulate their content, etc.
$(this).hide() - Hide the current element
(1)
Get the content - text(), html() and val()
gets the value of an attribute - attr() method is used to get the value of an attribute
Three simple and useful jQuery methods for DOM manipulation:
    text() - set or return the text content of the selected element
    html() - set or return The content of the selected element (including HTML tags)
    val() - set or return the value of the form field --- eg: $("#test").val() is often used to get the value
to get a tag href:
attr() method : $("#w3s").attr("href") Get the href value with the id of w3s
(2)
Set the content - text(), html() and val()
Add new HTML content:
    append() - insert content at the end of the selected element
    prepend() - at the end of the selected element Insert content at the beginning of the element
    after() - Insert content after the selected element
    before() - Insert content before the selected element
(3)
Remove:
To remove elements and content, you can generally use the following two jQuery methods:
    remove() - removes the selected element (and its children)
    empty() - removes children from the selected element to
filter the removed elements: Accepts one parameter, allowing you to filter the
removed elements to remove all <p> elements with class="italic": $("p").remove(".italic")

[jQuery - AJAX]
jQuery load() method It is a simple but powerful AJAX method that loads data from the server and puts the returned data into the selected element
$(selector).load(URL,data(optional),callback(optional))


ajax encapsulates ui chain Manipulate grayscale function iterator delay object 
1. style
2. DOM
3. event
4. animation

Guess you like

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