Last active
December 20, 2015 14:18
-
-
Save WenLiangTseng/6145104 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
<script type="text/javascript"> | |
jQuery(document).ready(function($){ | |
$('.alphabet').click(function(){ | |
$(this).addClass('active').siblings().removeClass('active'); | |
abc = $(this).data('abc'); | |
$('.xxx').each(function(){ | |
if ( abc == 'all' ) { | |
$(this).css('display','block'); | |
} else { | |
if ( $(this).data('abc') == abc ) { | |
$(this).css('display','block'); | |
} else { | |
$(this).css('display','none'); | |
} | |
} | |
}); | |
}); | |
}); | |
</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 | |
$abc_list = array( "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "all"); | |
echo "<ul id='abc_button_list' >"; | |
foreach( $abc_list as $abc ){ | |
echo "<li class='alphabet' data-abc='"; | |
echo $abc; | |
echo "' >" . $abc ; | |
echo "</li>"; | |
} | |
echo "</ul>"; | |
?> | |
<?php $item_name = 'cat'; ?> | |
<ul> | |
<li class="xxx" data-abc="a" >Apple</li> | |
<li class="xxx" data-abc="b" >Banana</li> | |
<li class="xxx" data-abc="<?php strtolower( $item_name[0] ); ?>" ><?php echo $item_name; ?></li> | |
</ul> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment