I'd like to ask:
In Blazor, how to pass event target (or this) to my JavaScript?
The thing is I'm creating inputs with @foreach so there can be a number of them.
Here is how it looks like:
@foreach (Item in ItemsList)
{
<input
@onchange="ChangeColor"
value="@Item.Value">
}
I want to simple onchange trigger this function:
@code
{
async Task ChangeColor()
{
await JsRuntime.InvokeVoidAsync("changeColor");
}
}
And eventually read the value in my JS:
function changeColor (el) {
console.log(el);
}
I tried using @ref, however I'd like to get access to the input that triggers the function. Since there may by many of them, I don't want to hardcode it using @ref to each of them.