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?
Asked
Active
Viewed 41 times
-1
-
I think you have a tag that shouldn't be there. `c#` – Max Oct 18 '15 at 00:34
-
Is element suppose to be checked using JavaScript ? – Rayon Oct 18 '15 at 01:47
1 Answers
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
});

Daniel Hoffmann-Mitscherling
- 2,339
- 1
- 16
- 23
-
2I 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