How do I get the particular element instance when an event is registered for multiple elements having same class ?
当为具有相同类的多个元素注册事件时,如何获取特定元素实例?
Code
Event.observe(document, 'dom:loaded', initBookingHistory);
function initBookingHistory()
{
hideJourneyDetails();
ObserveJourneyDetailsForClick();
}
function ObserveJourneyDetailsForClick()
{
$$('.Journey_Details div#Journey_Detail div.head h2 span.wrap').each(function(ele)
{
Event.observe(ele,'click', showOrHideJourneyDetails(ele));
})
}
function showOrHideJourneyDetails(ele)
{
ele.show();
}
Error
I get an "Handler is undefined" error
我收到“Handler is undefined”错误
1 个解决方案
#1
Do you mean events like onClick? If that's what you think, you use onclick="do_something(this)"
你的意思是像onClick这样的事件吗?如果这是你的想法,你使用onclick =“do_something(this)”
#1
Do you mean events like onClick? If that's what you think, you use onclick="do_something(this)"
你的意思是像onClick这样的事件吗?如果这是你的想法,你使用onclick =“do_something(this)”