Best practices:
- Save selection in a variable if the selection needs to make multiple time.
Explanation: jQuery doesn't do caching of selections and for every selection lot of code runs behind the scene - Use 'if($("element").length)' instead of
'if($("element"))' to make sure selection has records
Explanation: Any selection using $() always returns an object and object always evaluates to TRUE, even if selection doesn't contain any elements.
'if($("element"))' will return '[]' which is treated as empty object
1 comment:
Lovely post thanks for posting.
Post a Comment