-
Couldn't load subscription status.
- Fork 10.5k
Closed
Labels
area-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
Is there a way to obtain the event target element when handling an event from razor? I want to get a reference to the object onto which the event was dispatched. Let's say I have a razor component with the following code:
<div id="container" @onmousedown="HandleMouseDown">
<div id="nested">...</div>
<button>Submit</button>
</div>
@code {
private void HandleMouseDown(MouseEventArgs args)
{
// no way check which child element is the event target.
}
}
In javascript I can do the following.
var container = document.getElementById("container");
container.onmousedown = function(e) {
console.log(e.target);
};
Describe the solution you'd like
Add Target property to the MouseEventArgs which will return an ElementReference of the element onto which the event was dispatched.
Additional context
No response
Metadata
Metadata
Assignees
Labels
area-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components