jquery - Disabling every html DOM element excluding specific #id -
actually trying disable element in html page, there element want active.
$('body').find('*').attr('onclick',"return false;"); //disabling elements // trying make id("prerequisitedetails") active. $("#prerequisitedetails").parents().attr('onclick',null).off('click');
can tell me proper way this.
can tell me proper way this.
don't use onclick
attributes, use real event handlers.
this should it:
$('body') .find('*') .not($("#prerequisitedetails").parents().addback()) .click(false);
what does:
- finds elements descendants of
body
- from set, removes ones
prerequisitedetails
element or of parents. noteaddback
we're including element itself. - uses jquery shorthand click handler returns false.
although thinking it, sure want allow clicks on element's parents rather descendants? may want:
$('body') .find('*') .not($("#prerequisitedetails").find("*").addback()) .click(false);
that's above, elements leaves "enabled" prerequisitedetails
element , descendants.
it's bit brute-force, though. might questions , answers related modal dialogs, typically use shim element capture clicks, , position element want have "above" in front of element using z-index
.
Comments
Post a Comment