Search code examples
javascripthtmlfunc

How can i use return value of func. as integer with HTML?


<script>
function returnHEİGHT() {

    if (...)
        return 315;
    else
        return 639;
}
</script>

I want to use like this:

<video height=returnHEİGHT() width="639" controls>
 <source src="NGC.mp4" type="video/mp4">

I can use return value as string for print , if u use like this but i want integer value

<p id="demo" ></p>
document.getElementById("demo").innerHTML = 639;

Solution

  • <video id = "videoId"   width="639" controls>
     <source src="NGC.mp4" type="video/mp4">
    

    and you javascript

     $("#videoId").css("height", returnHEİGHT()+'px');