javascript - SIMPLE jQuery SELECT -
1) how alert when select 1_1.jpg, 1_2.jpg, 1_3.jpg or 2_1.jpg, 2_2.jpg, 2_3.jpg , other ones arn't selected? (something *_1.jpg, *_2.jpg, *_3.jpg)
2) how randomly position order of images (ex: first one: 2_1.jpg, second: 1_5, third:1_9 etc. end of src (_.jpg) should differe)?
http://jsfiddle.net/alecstheone/br4bs/
html:
<img class="image" src="../img/album1/1_1.jpg"> <img class="image" src="../img/album1/1_2.jpg"> <img class="image" src="../img/album1/1_3.jpg"> <img class="image" src="../img/album1/1_4.jpg"> <img class="image" src="../img/album1/1_5.jpg"> <img class="image" src="../img/album1/1_6.jpg"> <img class="image" src="../img/album1/1_7.jpg"> <img class="image" src="../img/album1/1_8.jpg"> <img class="image" src="../img/album1/1_9.jpg"> <img class="image" src="../img/album1/1_10.jpg"> <img class="image" src="../img/album1/2_1.jpg"> <img class="image" src="../img/album1/2_2.jpg"> <img class="image" src="../img/album1/2_3.jpg">
css:
.img { height:30px; width:30px; background:blue; margin-left:10px; } .selected { -moz-box-shadow: 0 0 7px 4px blue; -webkit-box-shadow: 0 0 7px 4px blue; box-shadow: 0 0 7px 4px blue; }
jquery:
$( ".image" ).click(function() { if($(this).hasclass("selected")) $(this).removeclass("selected"); else $(this).addclass("selected"); });
1) how alert when select 1_1.jpg, 1_2.jpg, 1_3.jpg or 2_1.jpg, 2_2.jpg, 2_3.jpg , other ones arn't selected? (something *_1.jpg, *_2.jpg, *_3.jpg)
get img
elements in array $("img")
, , condition on both src
, class
attributes in array.
2) how randomly position order of images (ex: first one: 2_1.jpg, second: 1_5, third:1_9 etc. end of src (_.jpg) should differe)?
get img
elements in array $("img")
, shuffle array, , append elements container. see here example.
Comments
Post a Comment