+ 4

Questions from challange, in html teg p style.height == style. width?

Heres the code <p id='p1' style='width:30;' onclick='f()'>128</p> f is a function function f() { var e = document.getElementById('p1'); e.style.height = e.innerHTML/2; e.innerHTML = e.innerHTML/2; } Questions is: What will be the width after 3 clicks? I tried it on playground, and have seen a.style property, a.style.height and s.style.width is empty, but correct answer is not empty.

5th May 2017, 7:02 AM
shaldem
shaldem - avatar
5 Antworten
+ 5
Yes, I thought soo too, width does not change, but in challange right answer is width will be 16, I think it wrong, but not shure, may be in some browsers it so. This code on playgraunde here https://code.sololearn.com/WicLe57VJrcd/?ref=app
5th May 2017, 7:12 AM
shaldem
shaldem - avatar
+ 5
My code is like challange, expect members a.style output. I have scrinshot with challange, but don't know how can add it here.
5th May 2017, 8:48 AM
shaldem
shaldem - avatar
+ 4
It's not my code, its question from challange, and where are no px there
5th May 2017, 7:09 AM
shaldem
shaldem - avatar
+ 4
Then who wrote the challenge doesn't know javascript. and the code is wrong and poorly written. whoever created the challenge didn't use pixel 'px', so it doesn't change anything and also inside click handler he didn't add 'px'. add this css..... #p1 { background-color: green; } now you will see the dimension when click PS: I didn't see the actual challenge code. my comment is based on your question and the code sample
5th May 2017, 8:41 AM
Apel Mahmod
Apel Mahmod - avatar
+ 3
use pixel (width:30px). After 3 clicks width will be the same (30px) because click handler doesn't change width, it just change the height. after 3 clicks height will be 16(px?)
5th May 2017, 7:11 AM
Apel Mahmod
Apel Mahmod - avatar