javascript - How do you get two divs have the same borderRadius? -


is right way match 2 divs?

var div2 = document.getelementsbyclassname("div2"); div2.style.borderradius = "100px"  document.getelementbyid("div1").style.borderradius = div2.style.borderradius; 

just newbie @ javascript.

just comment on code, document.getelementsbyclassname() returns htmlcollection, not single dom element. should use document.getelementbyid() or document.queryselector() if you're trying 1 element.

and don't want use js add styling, unless styling want use dynamic. case, should use css file , add class:

.round-border {   border-radius: 100px; } 

if still want use js add class instead of putting in html, can following:

document.getelementbyid("div1").classlist.add('round-border'); document.getelementbyid("div2").classlist.add('round-border'); 

this assuming gave html elements correct id names.

but said, because using static value of 100px, make more sense add class elements in html file.


Comments

Popular posts from this blog

javascript - Create websocket without connecting -

how to do line continuation in perl debugger for entering raw multi-line text (EOT)? -

Android SDK Manager freezes after installation of OSX 10.11 El Capitan public Beta -