2 days back when we enabled locker service document.getElementById('someid') was working. All of a sudden it stopped working and now gives undefined. i can see the div whose property i need to modify from browser F12. Please help.

  • 1
    I assume this is with LockerService activated based on the tags. Does the code work with LockerService off? Do you have any example code to look at? In general document.getElementById is functional, but there may be corner cases we missed. – TrevorBliss Jun 22 '16 at 17:21
  • Hi Trevor, Yes the code works fine when locker service is off, when locker service is on, the line document.getElementById('maindatascreen').style.setProperty('display', 'none'); does not work. when i check document.getElementById('maindatascreen') in console log, it gives undefined. – Gautam Maheshwari Jun 28 '16 at 10:50
  • There are several examples of getElementById working inside LockerService. If you have in markup: <div id="maindatascreen"/> then document.getElementById("maindatascreen") will return that element. If you edit your question and include your markup I can help debug it. – TrevorBliss Jun 28 '16 at 22:17

Try doing the same in the afterRender function in the renderer file.

afterRender: function(component, helper) {


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.