Last active
July 10, 2016 17:36
-
-
Save danielpataki/36d467f72129e4c6177ce13d8f61c032 to your computer and use it in GitHub Desktop.
Getting Started With jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery('.post .entry-title').addClass('better-entry-title') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery('#masthead .site-description').append( ", I'm also on WPMU DEV" ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery('.post:first').attr('id'); | |
| jQuery('.post:first').attr('id', 'the-first-post'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery('.post .entry-title a').css({ | |
| background: '#000000', | |
| color: '#ffffff', | |
| padding: '11px', | |
| borderBottom: '5px solid #F8E71C' | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery('.widget-title:eq(0)').css({ background: 'red' }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery(document).on( 'dblclick', '#masthead', function(){ | |
| jQuery('#masthead .site-description').text( 'You have found my double click easter egg!' ); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'wp_enqueue_scripts', 'jquery_test_assets' ); | |
| function jquery_test_assets() { | |
| wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); | |
| wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css' ); | |
| wp_enqueue_script( 'jquery-test', get_stylesheet_directory_uri() . '/scripts.js', array('jquery'), '1.0.0', true ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery('.widget-title:gt(2)').css({ background: 'red' }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery('aside').children().has('.widget-title').css({ background: 'red' }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // treats string as HTML outputting a an actual link | |
| jQuery('#masthead .site-description').html( 'Read me on <a href="http://premium.wpmudev.org/blog/author/danielpataki">WPMU DEV</a> as well' ) | |
| // trets string as text, outputs the string as-is | |
| jQuery('#masthead .site-description').text( 'Read me on <a href="http://premium.wpmudev.org/blog/author/danielpataki">WPMU DEV</a> as well' ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery('.widget-title').css({ background: 'red' }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery('.widget:not(.widget_categories) .widget-title').css({ background: 'red' }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery('#masthead').css({ background: 'red' }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Theme Name: Jquery Test Theme | |
| Description: A theme based on Twenty Sixteen for testing our jQuery prowess | |
| Author: Daniel Pataki | |
| Author URI: http://danielpataki.com | |
| Template: twentysixteen | |
| Version: 1.0.0 | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery('.widget').prepend( '<span class="toggle-widget">toggle</span>' ) | |
| jQuery( document ).on( 'click', '.toggle-widget', function() { | |
| jQuery(this).parent().find('*').not('.toggle-widget, .widget-title').toggle(); | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery('aside').children().find('h2').css({ background: 'red' }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment