Skip to content
Advertisement

Tag: innerhtml

Show/hide ‘div’ using JavaScript

For a website I’m doing, I want to load one div, and hide another, then have two buttons that will toggle views between the div using JavaScript. This is my current code The second function that replaces div2 is not working, but the first one is. Answer How to show or hide an element: In order to show or hide

How can I tell when changes to jquery html() have finished?

I’m using jQuery to change the HTML of a tag, and the new HTML can be a very long string. $(“#divToChange”).html(newHTML); I then want to select elements created in the new HTML, but if I put the code immediately following the above line it seems to create a race condition with a long string where the changes that html() is

Alternative for innerHTML?

EDIT: WOW. This question is 12 years old now. As someone stated, it can be done with a one-liner since 2016: https://stackoverflow.com/a/69322509/80907 The original: I’m wondering if there’s a way to change the text of anything in HTML without using innerHTML. Reason I’m asking is because it’s kinda frowned upon by the W3C. I know it’s nitpicking, but I just

Advertisement