In JavaScript, everything is ‘truthy’ or ‘falsy’, and for numbers 0
means false
, everything else true
. So you could write:
if ($(selector).length)
You don’t need that >0
part.
Related Contents:
- How do I redirect to another webpage?
- How can I remove all CSS classes using jQuery/JavaScript?
- JavaScript sleep/wait before continuing [duplicate]
- Detecting input change in jQuery?
- Switch statement for greater-than/less-than
- The data-toggle attributes in Twitter Bootstrap
- How to take screenshot of a div with JavaScript?
- How do I POST urlencoded form data with $http without jQuery?
- Count immediate child div elements using jQuery
- how to disable DIV element and everything inside [duplicate]
- jQuery/Javascript function to clear all the fields of a form [duplicate]
- Detect iPad users using jQuery?
- Using jQuery $(this) with ES6 Arrow Functions (lexical this binding)
- Choosing Mobile Web HTML5 Framework [closed]
- How to make script execution wait until jquery is loaded
- Object.watch() for all browsers?
- The $.param( ) inverse function in JavaScript / jQuery
- Placeholder for contenteditable div
- Trees in Twitter Bootstrap [closed]
- how to check if a form is valid programmatically using jQuery Validation Plugin
- JavaScript equivalent of jQuery’s extend method
- How to hide a div with jQuery?
- How to properly use jsPDF library
- Remove all items after an index
- How to get json key and value in javascript?
- jquery beforeunload when closing (not leaving) the page?
- jQuery-UI’s autocomplete not display well, z-index issue
- JavaScript eyedropper (tell color of pixel under mouse cursor)
- jQuery JSON to string?
- ReCaptcha 2.0: enable Submit button on callback if recaptcha successful
- Format numbers in JavaScript similar to C#
- Missing .map resource? [duplicate]
- How do I select a span containing a specific text value, using jquery?
- Cancel event on input type=”file”
- How to ONLY trigger parent click event when a child is clicked
- Select values of checkbox group with jQuery
- How to get a HTML element from a string with jQuery
- Insert content into iFrame
- How can I hide select options with JavaScript? (Cross browser)
- TypeError: $ is not a function WordPress
- Get the name (type) of the event that was fired (triggered)
- jquery : $().animate() is not a function
- Wait for async task to finish
- Flask Dynamic data update without reload page
- jQuery Title Case
- delay JQuery effects
- Switch case with conditions
- Dropzone – Uncaught Error: No URL provided
- How to check whether a select box is empty using JQuery/Javascript
- How is the jQuery selector $(‘#foo a’) evaluated?