What to learn today:
One, supplementary style operation
1. CSS (NAME|PRO|[,VAL|FN]) accesses the style attribute of the matching element $ ("P"). CSS ("color") gets the value of the color style property of the first paragraph
$ ("P"). css ({"Backgroud": "Bule", "COLCR": "Red"}) sets the font color of all paragraphs to red and the background to blue
$ ("P"). CSS ("Color", "red") to set all paragraph fonts to red
(Location dependent) * * *
2 position () Gets the offset of the matching element relative to the parent element. The returned object contains two integer properties: Top and left
3 offset ([coordinates]) gets the relative offset of the matching element at the current viewport. The returned object contains two integer properties: Top and left
4 ScrollTop ([Val]) Gets the offset of the match element relative to the top of the scrollbar this method is valid for both visible and hidden elements
5 ScrollLeft ([Val]) Gets the offset to the left of the matching element relative to the scrollbar. This method is valid for both visible and hidden elements
Second, the text operation
1 text ([VAL|FN]) Gets the contents of all matching elements$(‘p‘).text() 返回p元素的文本内容
$("p").text("Hello world!") 设置所有 p 元素的文本内容
2 HTML ([VAL|FN]) Gets the HTML content of the first matching element$(‘p‘).html() 返回p元素的内容
3 Val ([Val|fn|arr]) obtains the current value of the matching element $ ("input"). Val () Gets the value of the text box in $ ("input"). Val ( "hello world!"
) Sets the value of the text box
Third, attribute operation
1 prop (NAME|PROPERTIES|KEY,VALUE|FN) Gets the property value of the first element in a matching element set
$("input[type=‘checkbox‘]").prop("checked") 选中复选框为true,没选中为false
$("input[type=‘checkbox‘]").prop({
disabled: true
}) 禁用页面上的所有复选框
$("input[type=‘checkbox‘]").prop("disabled", false);
$("input[type=‘checkbox‘]").prop("checked", true);禁用和选中所有页面上的复选框
2 attr (NAME|PROPERTIES|KEY,VALUE|FN) Sets or returns the attribute value of the selected element
$("img").attr("src") 返回文档中所有图像的src属性值
$("img").attr({ src: "test.jpg", alt: "Test Image" })为所有图像设置src和alt属性
$("img").attr("src","test.jpg") 为所有图像设置src和alt属性
Iv. Event Binding
1 on (EVENTS,[SELECTOR],[DATA],FN) an event handler that is bound to one or more events in the selection element
$("p").on("click", function(){alert( $(this).text() );})
Python Day59 JQuery2