I have some HTML elements
<p class="accordion-header open" id="platform_0" onclick="validateScreens(this)">Platform 0</p>
<p class="accordion-header open" id="platform_1" onclick="validateScreens(this)">Platform 0</p>
<p class="accordion-header open" id="platform_2" onclick="validateScreens(this)">Platform 0</p>
I want to remove and restore the click event on this element. My JavaScript code is :
function validateScreens(domObj)
{
if(some condition)
{
$(domObj).off("click"); // //remove click from <p> whenever there is a click event
} else {
$(domObj).on("click",function() { return true; });// restores the click event
}
}
It is removing the click event successfully but not restoring it.How to do it.