Live Chat Icon For mobile
Live Chat Icon

Where should I access the DOM elements?

Platform: Blazor| Category : Components, JavaScript Interop

You have to access the DOM elements in OnAfterRender or OnAfterRenderAsync of the Blazor component lifecycle.

[JS Helper]

window.methods = {    
    accessDOM: function () {
        // access DOM here


@inject IJSRuntime JSRuntime

<button type="button" class="btn btn-primary">Submit</button>
    protected override void OnAfterRender(bool firstRender)

Have a look at the Blazor component lifecycle for more information.

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.