I have a div element to contain some information, how to use javascript to remove the…
Jump to turn (6)
- 1I have a div element to contain some information, how to use javascript to remov
- 2arrA={ "0": 1, "1": "Adult Incontinence - Pads", "catid": 1, "category": "Adult
- 3it doesn't work
- 4sorry, the arrB = ['2', '4'];
- 5if I want to check if 1 is exist in arrA's catid or not, how to do?
- 6sorry, the pass value is string '1'
- User
I have a div element to contain some information, how to use javascript to remove the content
- Assistant
inside the div element?
You can use JavaScript to remove the content inside a div element using the
innerHTMLproperty. Here's an example:HTML:
html<div id="myDiv"> This is some content inside the div. </div>JavaScript:
javascriptvar div = document.getElementById("myDiv"); div.innerHTML = "";In the above code, we first select the
divelement using itsidwith thegetElementByIdmethod. Then, we set theinnerHTMLproperty to an empty string, effectively removing the content inside the div. - User