Trying to determine if a specific CSS class exists within my HTML by using the .length method has left me puzzled. Despite researching extensively online, I continue to receive an "Object expected" error when implementing this approach.
<script type="text/javascript>
if ($(".deleteLink").length != 0)
{
$(".deleteLink").click(function () { return confirm('some message?'); });
}
</script>
The CSS class in question is ".deleteLink", associated with a particular tag that may or may not be present on the page. The conditional statement appears to be where the error arises.
Could it be possible that I am overlooking something crucial in my implementation? It's perplexing because most resources suggest using the .length technique...