Blazor WebAssembly doesn’t allow direct manipulation of DOM. Here is how to show/hide DOM element without using Javascript Interop;
The hidden html attribute also works to hide an element.
<p hidden>This paragraph should be hidden.</p>
To bind to Model:
 <p hidden="@HideLabel">I am Hidden When HideLabel == true</p>
 <p hidden="@(!HideLabel)">I am Hidden when Hidelabel == false</p>
    
 <button @onclick="@Toggle">Show/Hide</button>
 @code {
      private bool HideLabel { get; set; } = false;
      private void Toggle()
      {
         HideLabel =   !HideLabel;
      }      
 } 
Edit: You can also use a CSS class to hide/show an element:
<div class="font-italic @(HideLabel ? "d-none" : "d-show")">
   I am Hidden When HideLabel == true
</div>Reference
https://stackoverflow.com/questions/63693734/how-to-show-hide-an-element-in-real-time-blazor

 Add to favorites
Add to favorites