This time I will share jQuery Plugin and tutorial about jQuery Plugin For Convenient CSS Manipulation – CSS Extender, hope it will help you in programming stack.
The jQuery CSS Extender plugin extends & enhances the .css() method and provides more methods for easier CSS manipulation.
Features:
- Use raw CSS in .css().
- Use raw CSS blocks in .css().
- Reset CSS to default.
- Copy CSS from one to another element.
- Take or give CSS from one to another element.
How to use it:
1. Load the jQuery CSS Extender after loading the latest jQuery JavaScript library.
3 |
integrity = "sha256-3edrmyuQ0w65f8gfBsqowzjJe2iM6n0nKciPUp8y+7E=" |
4 |
crossorigin = "anonymous" > |
7 |
< script src = "./dist/jquery-css-extender.js" ></ script > |
2. Use raw CSS in the .css()
.
06 |
background-color: #ddd; |
09 |
box-shadow: 0 3px 0 #bbb; |
3. Use raw CSS in the .css()
.
06 |
background-color: #ddd; |
09 |
box-shadow: 0 3px 0 #bbb; |
4. Use raw CSS blocks in the .css()
.
01 |
$( '#button-container' ).css(
|
11 |
background-color: #ddd; |
14 |
box-shadow: 0 3px 0 #bbb; |
18 |
button:nth-of-type(2), button:nth-of-type(3) { |
21 |
button:nth-of-type(2) { |
22 |
border: 3px solid #bbb; |
5. Copy CSS from one to another.
1 |
$( '#element2' ).copyCss($( '#element1' )); |
6. Take or give CSS from one to another.
01 |
$( '#button-container' ).css(
|
03 |
justify-content: space-around; |
11 |
background-color: #ddd; |
14 |
box-shadow: 0 3px 0 #bbb; |
16 |
).giveCssTo($('#button2' )); |
18 |
$( '#button3' ).takeCss($( '#button2' )); |
7. Reset the CSS styles.
2 |
$( '#element' ).resetCss(); |
5 |
$( '#element' ).resetCss([ 'property 1' , 'property 2' ]); |
8. Handle the history of CSS changes.
02 |
$( '#element' ).cssHistory(); |
05 |
$( '#element' ).useCssHistorySystem( false ); |
08 |
$( '#element' ).useCssHistorySystem( true ); |
11 |
$( '#element' ).forgetCssHistorySystemOnce(); |
9. Handle the CSS states.
02 |
$( '#element' ).cssState( 'myState' , { 'color' : 'red' }); |
05 |
$( '#element' ).useCssFromState( 'myState' ); |
08 |
$( '#element' ).css( '...' ).cssStateFromCurrent( 'secondState' ); |
11 |
$( '#element' ).css( '...' ).defaultCssStateFromCurrent(); |
14 |
$( '#element' ).defaultCssState({...}); |
17 |
$( '#element' ).useDefaultCssState(); |
10. Event handlers.
1 |
$( '#element' ).cssStateOn( 'click' , 'myState' ); |
2 |
$( '#element' ).cssStateOnHover( 'myState' ); |
5 |
.cssState( 'default' , {...}) |
6 |
.cssState( 'hover' , {...}) |
source : jquery.net