On iOS, I want to disable scrolling on the <body> element only, not elements within the <body> element. The following code will disable dragging on the <body> element, but also prevents dragging on child divs:
$("body").bind("touchstart", function(e) {
e.preventDefault();
});
Is there anyway for this to just affect the parent div, not the child div’s within the parent (<body>)? I thought maybe $("#yourdiv").parent() would work, but no luck.
EDIT: This link, while it addresses the same issue, did not solve my problem: prevent app dragging but permit scroll of inner div elements in ios
You could check the
targetof the event – not 100% sure how this goes on iOS, but I’d assume it should be fine.Another possibility would be to stop the event from propagating in the first place.
But this is just a thought, and I’m also not entirely sure it would work.