jquery - Fallback if .clientHeight is null and there is no element -


i have 2 canvas elements on website. javascript checks height , wide of surrounding div , set canvas height , width it.

var height = parseint(document.getelementbyid("canvaselement").clientheight); var height2 = parseint(document.getelementbyid("canvaselement2").clientheight);

the problem if 1 of 2 canvas elements doesnt exist on subpage, script stops working.

the console gives me **uncaught typeerror: cannot read property 'clientheight' of null **

i tried like

if (height = null) {     console.log("height null"); }  

how can fallback if canvas element not present? ideas or suggestion?

regards denym


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -