In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to introduce JQuery.min.js files". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
JQuery sets content and properties
Set content-text (), html (), and val ()
We will use the three same methods in the previous chapter to set up the content:
? Text ()-sets or returns the text content of the selected element
? Html ()-sets or returns the contents of the selected element (including the HTML tag)
? Val ()-sets or returns the value of the form field
The following example shows how to set content through the text (), html (), and val () methods:
$("# btn1") .click (function () {
$("# test1") .text ("Hello world!")
})
$("# btn2") .click (function () {
$("# test2") .html ("Hello world!")
})
$("# btn3") .click (function () {
$("# test3") .val ("jpowernode")
})
Callback functions for text (), html (), and val ()
The above three jQuery methods, text (), html (), and val (), also have callback functions. The callback function takes two parameters: the subscript of the current element in the selected element list, and the original (old) value. Then return the string you want to use with the new value of the function.
The following example demonstrates text () and html () with callback functions:
$("# btn1") .click (function () {
$("# test1") .text (function (iorigText) {
Return "Old text: + origText +" New text: Hello world! (index: "+ I +") "
})
})
$("# btn2") .click (function () {
$("# test2") .html (function (iorigText) {
Return "Old html:" + origText + "New html: Hello world! (index:" + I + ")"
})
})
Set property-attr ()
The jQuery attr () method is also used to set / change property values.
The following example shows how to change (set) the value of the href property in a link:
$("button") .click (function () {
("# bjpowernode") .attr ("href", "")
})
The attr () method also allows you to set multiple properties at the same time.
The following example shows how to set both the href and title properties:
$("button") .click (function () {
("# bjpowernode") .attr ({
"href":
Title: jQuery tutorials
})
})
Callback function of attr ()
The jQuery method attr () also provides a callback function. The callback function takes two parameters: the subscript of the current element in the selected element list, and the original (old) value. Then return the string you want to use with the new value of the function.
The following example demonstrates the attr () method with a callback function:
$("button") .click (function () {
$("# bjpowernode"). Attr ("href", function (iMagneOriValue) {
Return origValue + "/ jquery"
})
})
This is the end of the introduction of "how to introduce JQuery.min.js files". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.