Given this simple ul
:
<ul class="dummy">
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
And this jQuery code:
var container = $('.dummy');
var active = container.children('li.active') || container.children('li:first-child')
console.log(active.html());
According to what I know about using ||
in variable assignment, I'd expect that the first li
should be selected, since there are no li.active
(see also this thread)
Instead, in the console.log
I get undefined
instead of One
: seems that the container.children('li:first-child')
is never evaluated
Where am I wrong? Here is a JSFiddle... Thanks a lot!