Skip to content

Get access to target clicked on  #2590

@caperaven

Description

@caperaven

Feature Request

In js you can use the event.target to see what the element is that you clicked on allowing you to have one click event but have more flexibility.

Implement Suggestion

For example

#[component]
pub fn menu() -> Element {
    rsx! {
        div {
            class: "menu-left",
            ul {
                onclick: move |event| {
                    if event.target.tag_name == "li" { ... }
                },

                li { "Home" }
                li { "About" }
                li { "Contact" }
                li { "Blog" }
            }
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthtmlRelated to the html crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions