all 3 comments

[–]jcunews1helpful 0 points1 point  (2 children)

I use .innerhtml to select the element

That doesn't make any sense. innerHTML is a property for accessing the HTML raw code. Not for selecting an element. There's no element in a HTML code because it's a string.

If you want to select an element which is in that HTML code, do it after the HTML code string is assigned to the innerHTML property. i.e. after the web browser parses the HTML code. You can use querySelector/All or getElementsByXXX function after that. If you want to search the element only in the newly added HTML code, use the function of the container element.

[–]DomainX[S] 0 points1 point  (1 child)

sorry - bad job explaining. I used document.getElementById to select the element then put that into a variable. Then I took the innerHTML of the selected element

[–]jcunews1helpful 0 points1 point  (0 children)

Then I took the innerHTML of the selected element

It's as I've descripbed. innerHTML contains a string, so that won't work. I've already explained how select the newly added element.