Link to home
Start Free TrialLog in
Avatar of PlumInternet
PlumInternet

asked on

Update HTML within a Div using document.getElementsByClassName

Hello,

We are attempting to update HTML within a div tag using .getElementsByClassName on pageload.

For example:

<div class="description ng-scope">
<p>Don't ask me.</p>
<p>I have no idea what it does.....</p>
</div>

Updated to:

<div class="description ng-scope">
<p>updated</p>
</div.

We have attempted to use:
<script>
document.getElementsByClassName("ng-scope").innerHTML = "<p>updated</p>";
</script>

But it doesnt seem to work just wondering whats wrong with my syntax. Note we cant use jQuery.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Ronak Patel
Ronak Patel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PlumInternet
PlumInternet

ASKER

Brilliant. Has solved the problem. Thanks for your help.
Hi PlumInternet,

If my answer helped you in resolving your problem, please mark it as an accepted answer ! :)


Regards,
Ronak
Doh, I thought I did. Sorry.
Its okay, no worries :)