-1

I want to give border radius to a div box in javascript as i have give in css as border:2px solid #000;

How can i give it inside the for loop given below.

elements = document.getElementsByClassName("box");
for (var i = 0; i < elements.length; i++) {
    elements[i].style.backgroundColor="#ff33ff";
}
Phil
  • 157,677
  • 23
  • 242
  • 245
wtp
  • 249
  • 1
  • 7
  • `elements[i].style.borderRadius = ...` – Phil Sep 26 '18 at 01:13
  • @phil elements[i].style.borderRadius = "2px solid #000"; didn't produce the output – wtp Sep 26 '18 at 01:17
  • 1
    That's because `2px solid #000` is a `border` specification, not a `border-radius` one. I recommend reading the documentation ~ https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius – Phil Sep 26 '18 at 01:18

1 Answers1

3

Simply you can do it by :

object.style.borderRadius = "1-4 length|% / 1-4 length|%|initial|inherit"

Like this:

elements[i].style.borderRadius = "25px";
SOS9GS
  • 362
  • 1
  • 7