jquery turn preventdefault on and off
-
12-11-2019 - |
سؤال
Here's what I tried so far:
var preventDefaultFunc = function(e){
e.preventDefault();
}
then I call it in the click function later:
$('.item').click(function(e){
var $this = $(this);
var $thisChild = $this.find('.item-content');
if ( $this.hasClass('big') ) {
return false;
}
$this.on(preventDefaultFunc);
// make the box bigger and load the article inside it here
});
I did it this way so I can turn it off again later, because the div in question needs to allow clicks within it once it's made big.
The on/off switch isn't working, since it's supposed to stop the page from loading the link within the box, so that I can make the box bigger and load the article with ajax instead. Note that on/off is the jquery 1.7 version of bind/unbind.
Any suggestions?
لا يوجد حل صحيح
لا تنتمي إلى StackOverflow