Skip to content

Instantly share code, notes, and snippets.

@whyisjake
Created October 26, 2011 23:48
Show Gist options
  • Save whyisjake/1318362 to your computer and use it in GitHub Desktop.
Save whyisjake/1318362 to your computer and use it in GitHub Desktop.
Looking for an easy way to load a php array into some jQuery... Any ideas on how to simplify this?
<script>
<?php $arr = array(185,4,171); ?>
$(document).ready(function(){
/* Put your jQuery here */
$('.post-4').hide();
$('.post-171').hide();
$('.click185').addClass('active');
$('.click185').click(function() {
$('.post-4,.post-171').hide();
$('.post-185').show();
$('.click185').addClass('active');
$('.click171, .click4').removeClass('active');
});
$('.click4').click(function() {
$('.post-185,.post-171').hide();
$('.post-4').show();
$('.click4').addClass('active');
$('.click171, .click185').removeClass('active');
});
$('.click171').click(function() {
$('.post-171').show();
$('.post-4,.post-185').hide();
$('.click171').addClass('active');
$('.click4, .click185').removeClass('active');
});
})
</script>
@whyisjake
Copy link
Author

Ty, this is awesome. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment