Gus000 Gus000 - 3 months ago 15
Javascript Question

how to expand onclick <video>

here's my html code:

echo "<div>";
echo '<video controls><source src="stuff/' . $entry . '"></video>';
echo "</div>";


here's my js code:

<script>
var videou = $( "video" ).attr("width", "150") + $( "video" ).attr("height", "80");
$( "video" ).click(function()
{
$(this).attr("width","500");
$(this).attr("height","500");
var open = true;
});
</script>


i want to go back to the original attributes. But i already tried everything. Should i use divs?

Answer

Your question is hard to understand, but based on your js code, maybe is this what you want

<script> 
var open = false;
$( "video" ).attr("width", "150"); 
$( "video" ).attr("height", "80"); 
$( "video" ).click(function() 
    {
    if(open){
        $(this).attr("width","150");
        $(this).attr("height","80");
        open = false;
    }else{
        $(this).attr("width","500");
        $(this).attr("height","500");
        open = true;
    }
    }
);
</script>
Comments