当前位置:网站首页>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
边栏推荐
- 关于回溯问题中的排列问题的思考(LeetCode46题与47题)
- Generate directories from web content
- Dlopen() implements dynamic loading of third-party libraries
- C language standard IO function sorting
- Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
- Redis: operation command of string type data
- 玖逸云黑免费无加密版本源码
- Go language web development series 27: Gin framework: using gin swagger to implement interface documents
- concat和concat_ws()区别及group_concat()和repeat()函数的使用
- 八大排序
猜你喜欢

消息订阅与发布

28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;

Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?

GoLand 2021.2 configure go (go1.17.6)

QT learning 23 layout manager (II)

玖逸云黑免费无加密版本源码

Qt学习22 布局管理器(一)

小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。

Failure of vector insertion element iterator in STL

3D vision - 2 Introduction to pose estimation - openpose includes installation, compilation and use (single frame, real-time video)
随机推荐
项目协作的进度如何推进| 社区征文
Duet date picker (time plug-in that can manually enter the date)
QT learning 23 layout manager (II)
QT learning 20 standard dialog box in QT (middle)
Exercise 8-7 string sorting
page owner特性浅析
玖逸云黑免费无加密版本源码
Qt学习19 Qt 中的标准对话框(上)
How to promote the progress of project collaboration | community essay solicitation
[combinatorics] permutation and combination (two counting principles, examples of set permutation | examples of set permutation and circle permutation)
Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
JVM family - overview, program counter day1-1
Simulated access
交联环糊精金属有机骨架负载甲氨蝶呤缓释微粒|金属-有机多孔材料UiO-66负载黄酮苷类药物|齐岳
Raft 协议
Page generation QR code
Using registered classes to realize specific type matching function template
How to bold text in AI
[acnoi2022] guess numbers
Exercise 6-2 using functions to sum special A-string sequences