jquery .add() is weird
Posted
by phil
on Stack Overflow
See other posts from Stack Overflow
or by phil
Published on 2010-06-06T05:26:22Z
Indexed on
2010/06/06
5:32 UTC
Read the original article
Hit count: 288
jQuery
Hi folks. Why all elements turn red? I only intend to turn <p> red.
<ul>
<li>list item 1</li>
<li>list item 2</li>
<li>list item 3</li>
</ul>
<p>a paragraph</p>
<script>
$('li').add('p').css('background-color', 'red');
</script>
© Stack Overflow or respective owner