Reputation: 343
I am beginning to dabble in Jquery and javascript and was looking for some advice please. I have below, the following code which makes a video transparent when I click on the image. However, what code would I need to make the image transparent too, upon click?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
</script>
<script>
$("#MinecraftVideo").animate({
opacity: '0.0'
});
$(document).ready(function () {
$("#picture_on").click(function () {
$("#MinecraftVideo").animate({
opacity: '1.0'
});
});
});
</script>
The image has the id="picture_on"
Many thanks
Upvotes: 0
Views: 40
Reputation: 1046
You can use the this
selector. This select the element you click on (the image).
<script>
$(document).ready(function () {
$("#picture_on").click(function () {
$("#MinecraftVideo").animate({
opacity: '1.0'
});
$(this).animate({opacity: '0'});
});
});
</script>
Upvotes: 1