album_name = Precious
如何獲得呢?
<html>
<head>
<title></title>
</head>
<body>
<div id="ps_slider" class="ps_slider">
<div id="ps_albums">
<div class="ps_album">
<div class="ps_image">
<div class="ps_img">
<img src="puppies/Snoopy/primary.jpg" alt="Dachshund Puppy Thumbnail"/>
</div>
</div>
</div>
<div class="ps_album">
<div class="ps_image">
<div class="ps_img">
<img src="puppies/Precious/primary.jpg" alt="Dachshund Puppy Thumbnail"/>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
var $ps_albums = $('#ps_albums');
$ps_albums.children('div').bind('click',function(){
var $elem = $(this);
var album_name = 'album' + parseInt($elem.index() + 1);
console.log(album_name);
});
});
</script>
</body>
</html>