Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Learn More

button event

more options

my button event contains a name that I can access in ie/edge using e.srcElement.actionName and in chrome using e.path[0] .actionName but I am unable to find where it is in the event object returned in Firefox

my button event contains a name that I can access in ie/edge using e.srcElement.actionName and in chrome using e.path[0] .actionName but I am unable to find where it is in the event object returned in Firefox

Được chỉnh sửa bởi Pedaars vào

Tất cả các câu trả lời (5)

more options

Hi Pedaars, I am not familiar with [node].actionName. What does that return, exactly?

For example, is it the value of the name attribute in the button:

<button name="buy" onclick="doStuff(this)">

or is it referring to the action that triggered the event, like "click"?

more options

it is a custom property in a stencilJS button component

more options

A custom property of an HTML node? Is it an attribute of the tag?

Regarding event.path there is a pattern to extend that to browsers which use the standardized method composedPath in the following reply. Maybe it will help?

https://stackoverflow.com/a/39245638

more options

yes it is an attribute of the tag

more options

Pedaars said

yes it is an attribute of the tag

So could you change from

event.srcElement.actionName

to

event.target.getAttribute('actionName')

(You only need srcElement if you are supporting IE8 and earlier)