contents().find() not producing the same result as changing selector context? - jQuery

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-06-09T19:02:06Z Indexed on 2010/06/09 19:12 UTC
Read the original article Hit count: 118

Filed under:

Hello all,

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!

© Stack Overflow or respective owner

Related posts about jQuery