Last active
December 13, 2016 23:14
-
-
Save Shelob9/e160541097a125669ebe29f5a3c7b4b0 to your computer and use it in GitHub Desktop.
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
<div id="main"> | |
<div class="entry-content" id="post-1"> | |
Hi Roy! | |
</div> | |
<div class="entry-content" id="post-2"> | |
Hi Shawn! | |
</div> | |
</div> | |
<script> | |
jQuery(document).ready(function($) { | |
$( '.entry-content' ).css( 'background-color', '#fff' ); | |
$( '#post-2' ).css( 'padding-bottom', '20px' ); | |
}); | |
</script> |
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
$( '#important-link' ).on( 'click', function( event ){ | |
//don't naviagate on click | |
event.preventDefault(); | |
//do SOMETHING ELSE when link with ID #important-link is clicked | |
}); |
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
$( '#important-link' ).on( 'click', function( event ){ | |
//do something when link with ID #important-link is clicked | |
}); |
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
<a href="#" id="hide-post-7">Hide</a> | |
<div id="post-7"> | |
<!-- put post 7 here --> | |
</div> | |
<script> | |
jQuery(document).ready(function($) { | |
$( '#hide-post-7' ).on( 'click', function(event){ | |
event.preventDefault(); | |
$( '#post-7' ).hide(); | |
}); | |
}); | |
</script> |
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', function(){ | |
wp_enqueue_script( '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
if ( have_posts() ) { | |
while ( have_posts() ) { | |
the_post(); | |
echo '<div>'; | |
echo '<a href="#" class="hide-post">Hide</a>'; | |
echo '<h1>' . get_the_title() .'</h1>'; | |
echo get_the_content(); | |
echo '</div>'; | |
} | |
} |
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).ready(function($) { | |
//$ is now 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
(function($) { | |
//$ is now jQuery | |
})(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(document).ready(function($) { | |
$( '.hide-post' ).on( 'click', function( event ){ | |
event.preventDefault(); | |
$( this ).parent().hide(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment