当前位置:网站首页>JQ style, element operation, effect, filtering method and transformation, event object
JQ style, element operation, effect, filtering method and transformation, event object
2022-07-03 04:56:00 【Wangzai delicious sugar】
1.jq And DOM Object conversion :
- DOM Convert to jq object : $(‘DOM object ’)
- jq Convert to DOM object :
(1)$(‘div’)[index]
(2)$(‘div’).get[index]------index Reference no. 2.jq Style operation :
Set class style : There is no need to add points to the parameters in the operation class
- Add the class :$(“div”).addClass(“current”);
- Remove class :$(“div”).removeClass(“current”);
- Switch classes :$(“div”).toggleClass(“current”);
3.jq Element operation :
Get elements :
- Get the inherent attribute value, such as a Of the link href ,title etc. :element.prop(“ Property name ”)
- Set up :$(“a”).prop(“ Property name ”,“ Later attribute value ”);
- Get element custom attribute value attr():attr(“ Property value ”)
- Set up :attr(“ attribute ”,“ Property value ”)
Traversing elements : Do different operations on the same type of elements
$("div").each(function(index,domEle){
xxx;})
In callback function 2 Parameters :index Index number for each element ;domEle yes DOM Element object , If you use jq Method , It needs to be converted to jq object $(domEle)
Additive elements
(1) Add... Inside
- $(“ul”).append(li); Add to the end of the content
- $(“ul”).prepend(li); Add to the front of the content
(2) External addition
- element.after(“ Content ”)— After the target element
- emement.before(“ Content ”)— Before the target element
notes : Add elements inside , After generation, the parent-child relationship , The external elements are added as brothers
Remove elements
- $("ul’).remove();— Delete ul
- $(“ul”).empty();— Delete ul Child nodes in
- $(“ul”).html(" ");— Delete ul Child nodes in
4.jq effect : Add... Before each effect stop() To stop queuing

The first two grammars :
show([speed],[easing],[fn])
(1)speed: Speed string (“show”,“normal”,“last”) Or the animation duration in milliseconds
(2)easing: Switching effect The default is "swing’( Slow first , In the middle is fast , Last slow ), You can use "linear"( uniform )
(3)fn: Callback function , Execute the function when the animation is finished , Each element is executed once
Fade in and fade out grammar :
fadeTo([speed],poacity,[easing],[fn])
among opacity Transparency must be written ,0-1 Between
Custom animation :
animate(params,[speed],[easing],[fn])
params: The style properties you want to change , Pass... As an object , Must write . Property names can be without quotes , If the attribute value is a number, no unit can be added , If it is a composite attribute Application borderLeft Hump nomenclature
$(function(){
$("button").click(function(){
$("div").animate({
left:500,
top:300
},500)
})
])
5. Screening method
- partent() : Only find the nearest parent -----$(“li”).partent();
- partents() : Find all parents ----$(“li”).partents(“zzz”) That is to find the name zzz The father of
- children(selector) : The nearest child —$(“ul”).children(“li”) amount to $(“ul>li”)
- find(selector): Select all children —$(“ul”).find(“li”) Find out ul All of the li
- siblings(slector): Choose brother , Not including myself —$(".one").siblings(“li”)
- eq(index): Choose the same number —$(“li”).eq(2)
- first() : $(“div p”).first()—div The first of p
- last() : $(“div p”).last()—div Last of p
6.jq event :
(1) Event handling on(): Assign the event on the original child element to the parent element ; Bind events to dynamically created elements in the future
$("ul").on("click","li",function(){
alert(11);
});
Trigger object li, React ul
(2) Event handling off()
- $(“p”).off()— relieve p All events of the element
- $(“p”).off(“click”)— relieve p Click events for
- $(“ul”).off(“click”,“li”) Release event delegation
(3) Stop the incident
- Block default :event.prentDefault() or return false;
- To prevent a bubble :event.stopPropagation()
边栏推荐
- Market status and development prospect prediction of global fermented plant protein industry in 2022
- Actual combat 8051 drives 8-bit nixie tube
- Review the old and know the new: Notes on Data Science
- Leetcode simple question: check whether two string arrays are equal
- Market status and development prospects of the global automatic tea picker industry in 2022
- Without 50W bride price, my girlfriend was forcibly dragged away. What should I do
- Market status and development prospect prediction of the global fire alarm sensor industry in 2022
- Cross platform plug-in flutter for displaying local notifications_ local_ notifications
- Thesis reading_ Chinese NLP_ ELECTRA
- Market status and development prospects of the global IOT active infrared sensor industry in 2022
猜你喜欢

论文阅读_ICD编码_MSMN

Mobile terminal - uniapp development record (public request encapsulation)

Leetcode simple question: check whether two string arrays are equal

Shuttle + alluxio accelerated memory shuffle take-off
![[research materials] the fourth quarter report of the survey of Chinese small and micro entrepreneurs in 2021 - Download attached](/img/01/052928e7f20ca671cdc4c30ae55258.jpg)
[research materials] the fourth quarter report of the survey of Chinese small and micro entrepreneurs in 2021 - Download attached
![[research materials] 2022q1 game preferred casual game distribution circular - Download attached](/img/13/5a67c5d08131745759fdc70a71cf0f.jpg)
[research materials] 2022q1 game preferred casual game distribution circular - Download attached

2022-02-11 daily clock in: problem fine brush

Leetcode simple question: check whether the array is sorted and rotated

Review the old and know the new: Notes on Data Science
![[research materials] annual report of China's pension market in 2021 - Download attached](/img/24/622aeeb38de16ac84128b362ceeddb.jpg)
[research materials] annual report of China's pension market in 2021 - Download attached
随机推荐
1111 online map (30 points)
Prepare for 2022 and welcome the "golden three silver four". The "summary of Android intermediate and advanced interview questions in 2022" is fresh, so that your big factory interview can go smoothly
Online VR model display - 3D visual display solution
Thesis reading_ ICD code_ MSMN
Day 51 - tree problem
Notes | numpy-08 Advanced index
Cross platform plug-in flutter for displaying local notifications_ local_ notifications
Hire cashier (differential constraint)
Use Sqlalchemy module to obtain the table name and field name of the existing table in the database
1103 integer factorization (30 points)
The programmer resigned and was sentenced to 10 months for deleting the code. JD came home and said that it took 30000 to restore the database. Netizen: This is really a revenge
Leetcode simple question: check whether the string is an array prefix
ZABBIX monitoring of lamp architecture (2): ZABBIX basic operation
MPM model and ab pressure test
The process of browser accessing the website
1107 social clusters (30 points)
移动端——uniapp开发记录(公共请求request封装)
MediaTek 2023 IC written examination approved in advance (topic)
1110 complete binary tree (25 points)
Handler understands the record