Save this code in a .JS file with the name of your choice. Then declare between the Header tags of your index page. For Blazor Webassembly applications it’s in the wwwwroot/index.html folder. For Blazor Server applications it’s in the _Host.cshtml file.
I don’t think I can teach you anything by telling you it’s like this:
What about the Blazor code?
Just add the interface IJSRuntime to your page .razor. As our code javascrpit returns nothing, it will then be enough to call it via InvokeVoidAsync :
<input Id="idPassWord" Type="password" @bind="_pass" />
private string _pass;
private async void clickOK()
// your code
public async Task Focus(string elementId)
await js.InvokeVoidAsync("jsfunction.focusElement", elementId);
Once again, you will have understood it, it’s super simple!address