0
Problem with my code, check description.
In js: function change(){ var x = document.getElementById('het'); if (x.style.display === 'none') { p.style.display = 'none'; x.style.display = 'block; }else{ p.style.display = 'block'; x.style.display = 'none; } } I'm using this to toggle the display of a paragraph but how do I code the x.style.___ part for font family since its two words ?
4 odpowiedzi
+ 3
Try
x.style['font-family'] = 'something'
It's another way to access properties of any object.
+ 2
use camelCase.
when there are two words or more, write them together, with them uppercased starting from the second one.
like "backgroundColor" "fontFamily".
so your code would be for exemple:
x.style.fontFamily = 'Arial';
+ 1
p.style.fontFamily = 'Arial';
0
Thanks guys!