Home > Net >  How can I use padding-inline-start with document.getElementById()?
How can I use padding-inline-start with document.getElementById()?

Time:08-29

Can someone help me how to write the 2 lines correctly in this function:

  function Arabic_fun() {
            document.getElementsById("#navleft").style.padding - inline - start = "0px";
            document.getElementsById("#navleft li ul").style.padding - inline - start = "0px";
}

CodePudding user response:

Issues:

  1. No such function getElementsById. Did you mean getElementById?
  2. getElementById does not need a # in the parameter
  3. #navleft li ul is not a valid id. If you want nested selectors like in CSS, use querySelector (single) or querySelectorAll (multiple elements)
  4. padding - inline - start should be paddingInlineStart
function Arabic_fun() {
  document.getElementById("navleft").style.paddingInlineStart = "0px";
  document.querySelector("#navleft li ul").style.paddingInlineStart = "0px";
}
  • Related