can i use jquery with php varibles?
hello.
i have videos than i want to hide/show (or toggle) or click using the videos class. the problem is that the class changes and is in a loop. how can i put the changing class into a jquery function
this is the html
- <div class="musical-pictures">
<?php
$i=1;
while($i<=4)
{
$no = (rand(1,4));
echo'<div class="vid'.$no.'">
<video src="http://v2v.cc/~j/theora_testsuite/320x240.ogg" controls></video>
<audio>
<source src="assets/audio/audio'.$no.'.mp3" type="audio/mpeg" ></source>
<source src="assets/audio/audio'.$no.'.ogg" type="audio/ogg" ></source>
</audio>
<img src="assets/images/pic'.$no.'.jpg" alt="picture'.$no.'">
</div>';
$i++;
}
?>
</div>
this is the current jquery that plays the audio on hover:
- $(function(){
$('img').hover(
function() {
$(this).prev()[0].play()
},
function() {
$(this).prev()[0].pause()
})
})
now what i need to do is hide the videos until the img is clicked to show that video
i tried this code but it opens all the videos
- $(function(){
$('video').hide();
$('img').click(function() {
$('video').show('slow', function() {
alert('Animation complete.');
});
});
})
so how do i reference the videos class. i.e $('.vid1').hide();
but the number changes randomly because its in the while loop which is random.
??
thanks
ricky