javascript - jQuery - Bind Unbind click event depending of condition -
i need disable click event jquery mobile button depending if array empty or not. when location loads don't want user able click, once array has values, change that.
this have tried:
if (points.length != 0){ $('#addplaces').bind('click');} else{$('#addplaces').unbind('click');}
i have tried same condition with:
$('#addplaces').on('click'); $('#addplaces').off('click');
what doing wrong? thanks!
why wanna that. return event when array empty , continue execution otherwise.
$('#addplaces').on('click', function() { if (points.length === 0) { return } });
this way need not keep toggling event.
Comments
Post a Comment