Hi everyone!
I want to add an onclick event handler on a field , so that when clicked (or focus) to hide an element.
Here is my code:
function setOnFocus() { var preferredResource = document.getElementById("ral_preferredresource"); if (preferredResource){ alert("on click"); preferredResource.attachEvent("onclick", hideFormAssistant); } } function hideFormAssistant() { alert("in hideformassistant"); document.getElementById('tdRelatedInformationPane').style.display = 'none'; }
Any ideas why it doesn't work? It errors on this line
preferredResource.attachEvent("onclick", hideFormAssistant);
*This post is locked for comments
Not sure if this can be done with supported way. Unfortunately the supported way most of the times is just not enough. But yes it is best practice to use it when you can!
Shak,
You use "Dom manipulations" that are not supported - that's why your code doesn't work as it expected ;) . I would suggest to find supported way to resolve your scenario.
Figured it out. Had to use addEventListener
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156