当前位置:网站首页>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
边栏推荐
- Qt学习21 Qt 中的标准对话框(下)
- Using registered classes to realize specific type matching function template
- Common mixins
- 战略、战术(和 OKR)
- 7-10 calculate salary
- MySQL data processing value addition, deletion and modification
- Global event bus
- Exercise 9-1 time conversion
- Installation impression notes
- How to use lxml to judge whether the website announcement is updated
猜你喜欢

Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)

RocksDB LRUCache

Qt学习18 登录对话框实例分析

JVM class loading

Redis: operation command of string type data

QT learning 21 standard dialog box in QT (Part 2)

关于回溯问题中的排列问题的思考(LeetCode46题与47题)

Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)

UiO-66-COOH装载苯达莫司汀|羟基磷灰石( HA) 包裹MIL-53(Fe)纳米粒子|装载黄芩苷锰基金属有机骨架材料

Scroll detection, so that the content in the lower right corner is not displayed at the top of the page, but is displayed as the mouse slides
随机推荐
Toast UI editor (editor allows you to edit your markup document using text or WYSIWYG, with syntax highlighting, scrolling synchronization, real-time preview and chart functions.)
Exercise 8-7 string sorting
GoLand 2021.1: rename the go project
Redis: operation command of string type data
QT learning 17 dialog box and its types
Conversion function and explicit
Redis: commandes d'action pour les données de type chaîne
Example analysis of QT learning 18 login dialog box
Exercise 7-6 count capital consonants
关于回溯问题中的排列问题的思考(LeetCode46题与47题)
Webpage connection database ~ simple implementation of addition, deletion, modification and query complete code
从零开始的基于百度大脑EasyData的多人协同数据标注
Implementation of Muduo asynchronous logging
[acnoi2022] guess numbers
Onmenusharetimeline custom shared content is invalid, and the title and icon are not displayed
Fabric. JS document
C language standard IO function sorting
MySQL data processing value addition, deletion and modification
Folic acid modified metal organic framework (zif-8) baicalin loaded metal organic framework composite magnetic material (AU- [email
Message subscription and publishing