aboutsummaryrefslogtreecommitdiffstats
path: root/core/src/jquery/exists.js
blob: 8a8efdb5a63ad86320f04090066b8726b2bf43ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

import $ from 'jquery'

/**
 * check if an element exists.
 * allows you to write if ($('#myid').exists()) to increase readability
 *
 * @see {@link http://stackoverflow.com/questions/31044/is-there-an-exists-function-for-jquery}
 * @return {boolean}
 */
$.fn.exists = function() {
	return this.length > 0
}