In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail what is the difference between jQuery and JS, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
1 positioning element
JS
Document.getElementById ("elemt")
JQuery
$("# elemt") / / locate via id
$(".elemt") / / locate via class
$("div") / / locate through the tag
Note that the result returned by JS is this element, and the result returned by jQuery is an object of JS. In the following example, it is assumed that the element elemt has been located.
2 change the content of the element
JS
Elemt [XSS _ clean] = "test"
JQuery
Elemt.html ("test")
3 show hidden elements
JS
Elemt.style.display = "none"
Elemt.style.display = "block"
JQuery
Elemt.hide ()
Elemt.show ()
Elemt.toggle (); / / switch between showing and hiding
4 gain focus
JS and jQuery are the same, both elemt.focus ()
5 assign values to the form
JS
Elemt.value = "test"
JQuery
Elemt.val ("test")
6 get the value of the form
JS
Alert (elemt.value)
JQuery
Alert (elemt.val ())
7 the setting element is not available
JS
Elemt.disabled = true
JQuery
Elemt.attr ("disabled", true)
8 modify element style
JS
Elemt.style.fontSize=size
JQuery
Elemt.css ('font-size', 20)
JS
Elemt.className= "test"
JQuery
Elemt.removeClass ()
Elemt.addClass ("test")
9 Ajax
JS
Create your own objects and deal with such messy issues as browser compatibility.
JQuery
Get ("elemt.php?a=1&b=2", recall)
Postvalue = "a=b&c=d&elemt=123"
$.post ("elemt.php", postvalue, recall)
Function recall (result) {
Alert (result)
/ / if json is returned, do the following
/ / result = eval ('('+ result +')')
/ / alert (result)
}
10 determine whether the check box is selected
JQuery
If (elemt.attr ("checked") = = "checked")
Note: xxx.attr ("checked") = = true is not available.
About what is the difference between jQuery and JS to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.