Typically in JavaScript I do something like the below to verify an element does exist:
if (document.getElementById('lblUpdateStatus')) {
$("#lblUpdateStatus").text("");
}
But, using jQuery – how can I do the same type of thing?
jquery
Typically in JavaScript I do something like the below to verify an element does exist:
if (document.getElementById('lblUpdateStatus')) {
$("#lblUpdateStatus").text("");
}
But, using jQuery – how can I do the same type of thing?
Best Solution
$
returns an array of matching elements, so check the length property and you're good to go