SlideShare a Scribd company logo
1 of 13
Download to read offline
Lessons Learnt in
Jquery
Mouseover
Vs
Mouseenter
Mouseover vs Mouseenter
● Both events triggers when we move mouse-pointer from outer div to
inner div
● But mouseover triggers unnecessary when the the elements on which
we have set this event contains many inner divisions. So to avoid this
situation we can prefer mouseenter.
● Ex 1: http://jsfiddle.net/ZCWvJ/7/
● Ex 2:
Mouseout vs Mouseleave
● Both events triggers when we move mouse-pointer from inner div to
outer div.
● But mouseout triggers unnecessary when the the elements on which
we have set this event contains many inner divisions. So to avoid this
situation we can prefer mouseleave.
● Ex 2:
What is Hover event?
.is()
Vs
.hasClass()
.hasClass( ) vs .is( )
● .hasClass() checks whether given element has particular class or not.
● .is() is multipurpose by using which we can check whether the element has
particular id , class and element satisfies particular condition or not.
● Ex: $(“p”).is(“:hidden”), to check element is hidden or not?
$(“p”).is(“#mypara”), to check element has particular id or not?
$(“p”).is(“.mypara”), to check element has particular class or not?
$( "li:first" ).is( "li:last" ), to check only one list element is present or not?
Conflicts in elements visibility in css and html vs Jquery
CSS properties:
● visibility: hidden
● display: none
● opacity: 0
HTML :
● Type attribute of input
<input type=”hidden”>
JQuery:
● .hide() method
CSS
Property
Width and Height of
element on
screen
Cursor navigation
using tab key
Responds to
events
display: none 0 No No
visibility: hidden Yes No No
opacity: 0 Yes Yes Yes
Conflicts in elements visibility in css and html vs Jquery
In Jquery Elements hidden only if it satisfies following condition.
● They have a CSS display value of none.
● They are form elements with input type="hidden".
● Their width and height are explicitly set to 0.
● An ancestor element is hidden, so the element is not shown on the page.
Elements with visibility: hidden or opacity: 0 are considered to be visible, since they
still consume space in the layout.
An element is assumed to be hidden if it or any of its parents consumes no space in the
document. CSS visibility isn't taken into account.
Conflicts in elements visibility in css and html vs Jquery
$( elem ).css( "display", "none" ).is( ":hidden" ) == true
=> true
$( elem ).css( "visibility", "hidden" ).is( ":hidden" ) == true
=> false
$( elem ).css("opacity","0").is(":hidden") == true
=> false
.append() vs after() and prepend() vs before()
● append() & prepend() are for inserting content inside an element (making the
content its child).
● while after() & before() insert content outside an element (making the content
its sibling).
Ex: http://jsfiddle.net/k4raa2gh/1/
Questions ?
Thank
You

More Related Content

Viewers also liked

What is Learning Analytics about?
What is Learning Analytics about?What is Learning Analytics about?
What is Learning Analytics about?Martin Ebner
 
Reanimación Inicial del Enfermo Crítico
Reanimación Inicial del Enfermo Crítico Reanimación Inicial del Enfermo Crítico
Reanimación Inicial del Enfermo Crítico Gustavo Moreno
 
Light combact aircraft tejas
Light combact aircraft tejasLight combact aircraft tejas
Light combact aircraft tejasTeja Tms
 
AIM GLOBAL MARKETING/BUSINESS PLAN FOR COUNTRIES WITH NO BCO
AIM GLOBAL MARKETING/BUSINESS PLAN FOR COUNTRIES WITH NO BCOAIM GLOBAL MARKETING/BUSINESS PLAN FOR COUNTRIES WITH NO BCO
AIM GLOBAL MARKETING/BUSINESS PLAN FOR COUNTRIES WITH NO BCOJames B
 
Lernen 4.0 im Wandel der Digitalisierung
Lernen 4.0 im Wandel der DigitalisierungLernen 4.0 im Wandel der Digitalisierung
Lernen 4.0 im Wandel der DigitalisierungVolkmar Langer
 

Viewers also liked (7)

ADvertZ Deck-2
ADvertZ Deck-2ADvertZ Deck-2
ADvertZ Deck-2
 
What is Learning Analytics about?
What is Learning Analytics about?What is Learning Analytics about?
What is Learning Analytics about?
 
The Dragon Family Lawsuit
The Dragon Family Lawsuit The Dragon Family Lawsuit
The Dragon Family Lawsuit
 
Reanimación Inicial del Enfermo Crítico
Reanimación Inicial del Enfermo Crítico Reanimación Inicial del Enfermo Crítico
Reanimación Inicial del Enfermo Crítico
 
Light combact aircraft tejas
Light combact aircraft tejasLight combact aircraft tejas
Light combact aircraft tejas
 
AIM GLOBAL MARKETING/BUSINESS PLAN FOR COUNTRIES WITH NO BCO
AIM GLOBAL MARKETING/BUSINESS PLAN FOR COUNTRIES WITH NO BCOAIM GLOBAL MARKETING/BUSINESS PLAN FOR COUNTRIES WITH NO BCO
AIM GLOBAL MARKETING/BUSINESS PLAN FOR COUNTRIES WITH NO BCO
 
Lernen 4.0 im Wandel der Digitalisierung
Lernen 4.0 im Wandel der DigitalisierungLernen 4.0 im Wandel der Digitalisierung
Lernen 4.0 im Wandel der Digitalisierung
 

Similar to Lessons learnt in Jquery

jQuery Presentation
jQuery PresentationjQuery Presentation
jQuery PresentationRod Johnson
 
Web Development Course - JQuery by RSOLUTIONS
Web Development Course - JQuery by RSOLUTIONSWeb Development Course - JQuery by RSOLUTIONS
Web Development Course - JQuery by RSOLUTIONSRSolutions
 
Why You Shouldn't Write OO
Why You Shouldn't Write OO Why You Shouldn't Write OO
Why You Shouldn't Write OO Yehuda Katz
 
Organizing jQuery Projects Without OO
Organizing jQuery Projects Without OOOrganizing jQuery Projects Without OO
Organizing jQuery Projects Without OOYehuda Katz
 
High performance websites session1
High performance websites  session1High performance websites  session1
High performance websites session1amr elgarhy
 
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinWill your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinBarry Gervin
 
NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05lrdesign
 
Design Patterns for Tablets and Smartphones
Design Patterns for Tablets and SmartphonesDesign Patterns for Tablets and Smartphones
Design Patterns for Tablets and SmartphonesMichael Galpin
 
Maintainable JavaScript 2011
Maintainable JavaScript 2011Maintainable JavaScript 2011
Maintainable JavaScript 2011Nicholas Zakas
 
BDD, ATDD, Page Objects: The Road to Sustainable Web Testing
BDD, ATDD, Page Objects: The Road to Sustainable Web TestingBDD, ATDD, Page Objects: The Road to Sustainable Web Testing
BDD, ATDD, Page Objects: The Road to Sustainable Web TestingJohn Ferguson Smart Limited
 
Css layout
Css layoutCss layout
Css layoutclub23
 
Testing Web Applications Through User Interface Constraints (CASCON 2015 Talk)
Testing Web Applications Through User Interface Constraints (CASCON 2015 Talk)Testing Web Applications Through User Interface Constraints (CASCON 2015 Talk)
Testing Web Applications Through User Interface Constraints (CASCON 2015 Talk)Sylvain Hallé
 
Replicating the Swipe Gesture iPhone Gallery for mobile web– HTML5 – Part 2
Replicating the Swipe Gesture iPhone Gallery for mobile web– HTML5 – Part 2Replicating the Swipe Gesture iPhone Gallery for mobile web– HTML5 – Part 2
Replicating the Swipe Gesture iPhone Gallery for mobile web– HTML5 – Part 2Joseph Khan
 

Similar to Lessons learnt in Jquery (20)

jQuery
jQueryjQuery
jQuery
 
jQuery Presentation
jQuery PresentationjQuery Presentation
jQuery Presentation
 
Web Development Course - JQuery by RSOLUTIONS
Web Development Course - JQuery by RSOLUTIONSWeb Development Course - JQuery by RSOLUTIONS
Web Development Course - JQuery by RSOLUTIONS
 
Jquery
JqueryJquery
Jquery
 
jQuery besic
jQuery besicjQuery besic
jQuery besic
 
jQuery Behaviours
jQuery BehavioursjQuery Behaviours
jQuery Behaviours
 
Why You Shouldn't Write OO
Why You Shouldn't Write OO Why You Shouldn't Write OO
Why You Shouldn't Write OO
 
Organizing jQuery Projects Without OO
Organizing jQuery Projects Without OOOrganizing jQuery Projects Without OO
Organizing jQuery Projects Without OO
 
High performance websites session1
High performance websites  session1High performance websites  session1
High performance websites session1
 
jQuery
jQueryjQuery
jQuery
 
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinWill your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
 
Events - Part 2
Events - Part 2Events - Part 2
Events - Part 2
 
NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05
 
Javascript and DOM
Javascript and DOMJavascript and DOM
Javascript and DOM
 
Design Patterns for Tablets and Smartphones
Design Patterns for Tablets and SmartphonesDesign Patterns for Tablets and Smartphones
Design Patterns for Tablets and Smartphones
 
Maintainable JavaScript 2011
Maintainable JavaScript 2011Maintainable JavaScript 2011
Maintainable JavaScript 2011
 
BDD, ATDD, Page Objects: The Road to Sustainable Web Testing
BDD, ATDD, Page Objects: The Road to Sustainable Web TestingBDD, ATDD, Page Objects: The Road to Sustainable Web Testing
BDD, ATDD, Page Objects: The Road to Sustainable Web Testing
 
Css layout
Css layoutCss layout
Css layout
 
Testing Web Applications Through User Interface Constraints (CASCON 2015 Talk)
Testing Web Applications Through User Interface Constraints (CASCON 2015 Talk)Testing Web Applications Through User Interface Constraints (CASCON 2015 Talk)
Testing Web Applications Through User Interface Constraints (CASCON 2015 Talk)
 
Replicating the Swipe Gesture iPhone Gallery for mobile web– HTML5 – Part 2
Replicating the Swipe Gesture iPhone Gallery for mobile web– HTML5 – Part 2Replicating the Swipe Gesture iPhone Gallery for mobile web– HTML5 – Part 2
Replicating the Swipe Gesture iPhone Gallery for mobile web– HTML5 – Part 2
 

Lessons learnt in Jquery

  • 3. Mouseover vs Mouseenter ● Both events triggers when we move mouse-pointer from outer div to inner div ● But mouseover triggers unnecessary when the the elements on which we have set this event contains many inner divisions. So to avoid this situation we can prefer mouseenter. ● Ex 1: http://jsfiddle.net/ZCWvJ/7/ ● Ex 2:
  • 4. Mouseout vs Mouseleave ● Both events triggers when we move mouse-pointer from inner div to outer div. ● But mouseout triggers unnecessary when the the elements on which we have set this event contains many inner divisions. So to avoid this situation we can prefer mouseleave. ● Ex 2: What is Hover event?
  • 6. .hasClass( ) vs .is( ) ● .hasClass() checks whether given element has particular class or not. ● .is() is multipurpose by using which we can check whether the element has particular id , class and element satisfies particular condition or not. ● Ex: $(“p”).is(“:hidden”), to check element is hidden or not? $(“p”).is(“#mypara”), to check element has particular id or not? $(“p”).is(“.mypara”), to check element has particular class or not? $( "li:first" ).is( "li:last" ), to check only one list element is present or not?
  • 7. Conflicts in elements visibility in css and html vs Jquery CSS properties: ● visibility: hidden ● display: none ● opacity: 0 HTML : ● Type attribute of input <input type=”hidden”> JQuery: ● .hide() method
  • 8. CSS Property Width and Height of element on screen Cursor navigation using tab key Responds to events display: none 0 No No visibility: hidden Yes No No opacity: 0 Yes Yes Yes
  • 9. Conflicts in elements visibility in css and html vs Jquery In Jquery Elements hidden only if it satisfies following condition. ● They have a CSS display value of none. ● They are form elements with input type="hidden". ● Their width and height are explicitly set to 0. ● An ancestor element is hidden, so the element is not shown on the page. Elements with visibility: hidden or opacity: 0 are considered to be visible, since they still consume space in the layout. An element is assumed to be hidden if it or any of its parents consumes no space in the document. CSS visibility isn't taken into account.
  • 10. Conflicts in elements visibility in css and html vs Jquery $( elem ).css( "display", "none" ).is( ":hidden" ) == true => true $( elem ).css( "visibility", "hidden" ).is( ":hidden" ) == true => false $( elem ).css("opacity","0").is(":hidden") == true => false
  • 11. .append() vs after() and prepend() vs before() ● append() & prepend() are for inserting content inside an element (making the content its child). ● while after() & before() insert content outside an element (making the content its sibling). Ex: http://jsfiddle.net/k4raa2gh/1/