当前位置:网站首页>Learn to punch in today
Learn to punch in today
2022-07-03 14:09:00 【VIXeH】
jQuery
- Learned two ways of traversal
// The first main traversal dom object
$('div').each(function (index, domEle) {
console.log(index);
// The second parameter is dom object , First convert
console.log($(domEle));
})
// The second traversal method , It's mainly used to process data , You can traverse any object , Array etc.
$.each($('div'), function (i, element) {
// The first parameter is the index , The second is the corresponding value , similar java Of foreach
})
- How to set and get properties
about style In the properties of the :
Return property value
$(“p”).css(“ Property name ”);
Setting property values
$(“p”).css(“ Property name ”,“ Property value ”);
Set up multiple
$(“p”).css({“background-color”:“yellow”,“font-size”:“200%”});
For the attributes of the tag :
Returns the value of the property :
$(selector).prop(property)
Set properties and values :
$(selector).prop(property,value)
Use functions to set properties and values :
$(selector).prop(property,function(index,currentvalue))
Set multiple properties and values :
$(selector).prop({property:value, property:value,…})
Be careful
prop() Method to set or return the properties and values of the selected element .
When this method is used to return a property value , Then returns the value of the first matching element .
When this method is used to set the property value , Set one or more attributes for the set of matching elements / It's worth it .
Be careful :prop() Method should be used to retrieve property values , for example DOM attribute ( Such as selectedIndex, tagName, nodeName, nodeType, ownerDocument, defaultChecked, and defaultSelected).
For custom properties
Returns the value of the property :
$(selector).attr(attribute)
Set properties and values :
$(selector).attr(attribute,value)
Use functions to set properties and values :
$(selector).attr(attribute,function(index,currentvalue))
Set multiple properties and values :
$(selector).attr({attribute:value, attribute:value,…})
prop and attr You can get the attribute value , but prop We don't scan the source code to get it, but according to the information of the page .
- About new elements
With jquery Way to create :
var txt2=$("<p></p>")
Or by html()
How to add elements :
append() - In the selected element Inside Insert at the end of , Father and son
prepend() - In the selected element Inside Insert at the beginning of , Father and son
after() - In the selected element after Insert content , Brotherhood
before() - In the selected element Before Insert content , Brotherhood
Delete element mode :
remove() - Delete selected elements ( And its subelements )
empty() - Remove child elements from selected elements
边栏推荐
- JS general form submission 1-onsubmit
- Redis:Redis的数据结构、key的操作命令
- QT learning 24 layout manager (III)
- [acnoi2022] guess numbers
- RocksDB LRUCache
- Uniapp skills - scrolling components -1
- jvm-运行时数据区
- Exercise 8-7 string sorting
- GoLand 2021.1: rename the go project
- Solution to failure or slow downloading of electron when electron uses electron builder to package
猜你喜欢

Go language web development series 29: Gin framework uses gin contrib / sessions library to manage sessions (based on cookies)

Exercise 9-3 plane vector addition
[email protected])|制备路线"/>叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线

JS first summary

28: Chapter 3: develop Passport Service: 11: define attributes in the configuration file, and then obtain them in the code;

Interface for querying IP home

Go language web development series 26: Gin framework: demonstrates the execution sequence of code when there are multiple middleware

Metal organic framework MOFs loaded with non steroidal anti-inflammatory drugs | zif-8 wrapped Prussian blue loaded quercetin (preparation method)

QT learning 20 standard dialog box in QT (middle)

玖逸云黑免费无加密版本源码
随机推荐
Go language web development series 26: Gin framework: demonstrates the execution sequence of code when there are multiple middleware
JVM family - overview, program counter day1-1
使用vscode查看Hex或UTF-8编码
simpleParallax. JS (create poor visual effects for website pictures)
Use and design of Muduo buffer class
JS first summary
可编程逻辑器件软件测试
allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取
RocksDB LRUCache
QT learning 20 standard dialog box in QT (middle)
Why don't I have a rookie medal
Back to top implementation
1px problem of mobile terminal
Generate directories from web content
GoLand 2021.1: rename the go project
金属有机骨架(MOFs)抗肿瘤药载体|PCN-223装载甲硝唑|UiO-66包载盐酸环丙沙星([email protected])
Folic acid modified metal organic framework (zif-8) baicalin loaded metal organic framework composite magnetic material (AU- [email
Solution to failure or slow downloading of electron when electron uses electron builder to package
金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
Solve the problem of dormitory router campus network sharing login