-1

I want to check a checkbox that was added to the web page via JavaScript but the element is not in the webbrowser.document, how can I achieve this?

spenibus
  • 4,339
  • 11
  • 26
  • 35
Matt
  • 7
  • 3

1 Answers1

1

You must bind your events on an element that exist when the binding is run. To add an event to a dynamic element, use the .on() functionality in javascript, like the following:

$(document).on("click", "#selector", function(e){
  // Do stuff
});
  • 2
    I also answered this question, but mine was not as good as this answer so I deleted it. This guy's got it right. – Craig Burton Oct 18 '15 at 00:46
  • basically I've tried to use getelementbyid but this does not find the element even after the page has loaded and the element I am looking for is not in the html source of the webpage. – Matt Oct 18 '15 at 12:39