Skip to content

Instantly share code, notes, and snippets.

@mfields
Created May 10, 2011 14:17
Show Gist options
  • Save mfields/964552 to your computer and use it in GitHub Desktop.
Save mfields/964552 to your computer and use it in GitHub Desktop.
Hide submit button if it exists.
/* Hide submit button if it exists. */
var button = document.getElementById( 'my_submit_button' );
if ( null !== button && 'style' in button && 'display' in button.style ) {
button.style.display = 'none';
}
@ericmann
Copy link

The === and == operators behave exactly the same after doing type conversions. In the end, === is faster if the two sides are different types (because it skips type conversion and just returns false) but == is faster if the two types are the same.

In your case, particularly when using Yoda conditions, there's no benefit of using one or the other since you're comparing with null. It becomes a matter of preference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment