I have a function that looks somewhat like this:
function(domObj) {
var currentObj = $(domObj);
...
currentObj.contents().find(".ws").after("foobar");
}
My problem is that the above method of using .contents().find() is not working. “foobar” never gets stuffed after the specified dom element, represented by the selector, .ws
However if I do this:
$(".ws", currentObj).after("foobar");
Then the string, “foobar” gets appended every time.
My question:
Are not these two methods supposed to be equivilant? How/what am I doing wrong in my use of .contents().find() so that it is not working?
Thanks!
… is equivelant to:
contents()returns all child-nodes, and so therefore when you executecontents().find()you’re actually searching within the child-nodes, as opposed to searching the child-nodes themselves.