140
rated 0 times
[
141]
[
1]
/ answers: 1 / hits: 23944
/ 13 Years ago, tue, june 21, 2011, 12:00:00
How can I find out if a certain element has another element as a child?
And if it doesn't, append a new one to it and then return it.
I tried it with:
var myel = ($('> div.my', this).length > 0)
? $('> div.my', this)
: $(this).append('<div class=my></div>').css('opacity', 0);
but even though it creates my element if it doesn't exist, it doesn't return it...
More From » jquery