Jquery basic study notes_jquery
May 16, 2016 pm 06:52 PM1. Attribute: Set a calculated attribute value for all matching elements
//Add attribute class="btn" for all inputs
//$("input").attr("class ","btn");
2. CSS: Add the specified class name to each matching element
//Add styles to all submit buttons
$("input :submit").addClass("btn");
3. Value: Get the current value of the first matching element
//Get the value of a button
/ /alert($("#Button1").val());
4. Html code: Get the html content of the first matching element. This function cannot be used with XML documents. But it can be used for XHTML documents.
//Output the html code between divs
//alert($("#div1").html());
//Reassign the html in the Div
//$("#div1").html("");
5. Text: Get the content of all matching elements.
The result is the text combined from the text content contained in all matching elements. This method works for both HTML and XML documents.
//Output the text value between divs
//alert($("#div1").text());
//For the text value in the div Text reassignment
//$("#div1").text("100");
6. //Select the radio button
$("#select1").val( "Option 2");
// if( $("#select1").val()=='Option 2')
// {
// alert("You selected option 2 ");
// }
7. Convert one or more DOM elements into jQuery objects
//Set the page background color
$(document.body).css(" background","#c0c0c0");
//Hide all elements in a form [not available]
//$(div.elements).hide();
8 , each usage uses each matching element as the context to execute a function
// $("button").click(function () {
// $("div").each(function (index , domEle) {
// // domEle == this
// $(domEle).css("backgroundColor", "yellow");
// if ($(this).is( "#stop")) {
// $("span").text("Stopped at div index #" index);
// return false;
// }
// });
// });
9. The return value of this function is consistent with the 'length' property of the jQuery object
//The number of buttons
//alert($ ("input:submit").size() " and " $("input:submit").length);
10. Get the set of all matching DOM elements
//alert($( "input").get().reverse());
//Get one of the matching elements. num indicates which matching element is obtained
//alert($("input").get(1));

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Detailed explanation of jQuery reference methods: Quick start guide

How to use PUT request method in jQuery?

How to remove the height attribute of an element with jQuery?

jQuery Tips: Quickly modify the text of all a tags on the page

Use jQuery to modify the text content of all a tags

Understand the role and application scenarios of eq in jQuery

How to tell if a jQuery element has a specific attribute?

Summary of commonly used file operation functions in PHP
