javascript - jQuery.find() returns an object even when there's no matching child element in the DOM -
i trying find element id '' within element '', , therefore child.
i using $.find method perform search.
if child object found, i'd perform actions, , if child object isn't found, i'd different things.
however, though know there no such child element existing, jquery.find method reports object not sure, inspecting in watches window, is.
here's relevant code snippet:
function createresourcekeytextbox(resourcekeyid, editmode) { var resourcekeytablecell = $("#tdkeyresourcekeyid" + resourcekeyid); var resourcekeynametextbox = null; var alreadyexistingresourcekeynametextbox = resourcekeytablecell.find('#txtresourcekeyname' + resourcekeyid); if (alreadyexistingresourcekeynametextbox != null && typeof alreadyexistingresourcekeynametextbox != "undefined") { resourcekeytablecell.html(''); resourcekeynametextbox = alreadyexistingresourcekeynametextbox; resourcekeynametextbox.css('display', 'block'); resourcekeynametextbox.appendto('#tdkeyresourcekeyid' + resourcekeyid); resourcekeynametextbox.css('width', '96%'); }
jquery query functions return object, if there's no matching dom elements.
check length, 0
if there's no element in set :
if (alreadyexistingresourcekeynametextbox.length ...
Comments
Post a Comment