the jquery code $("#searchable.dynamic-content")
will match on an element that has the id searchable
and the class dynamic-content
.
That doesn't help us much, since in the code in the issue we are trying
to get at an element with the class dynamic-content
that is inside an element with the id searchable
. Assuming we have the following
html:
<div id="searchable">
<div class="dynamic-content">...content here...</div>
</div>
the first selector won't match on anything. It would only match if we added the class dynamic-content
to the outer div that
has an id of searchable
. However, if we add the space between #searchable
and .dynamic-content
, we are telling jQuery that we
want an element with the class dynamic-content
that is inside (aka a child of) the element with the id searchable
.
In your example, $("#friendlist#friends")
, you are telling jquery to look for an element with the id friendlist
and the idfriends
,
which is not a valid selector, since an element should only have one id
attribute. If you were to put a space between the two,
$("#friendlist #friends")
, it would match on the following:
<div id="friendlist">
<div id="friends"> <!-- Matches this element--></div>
</div>
see this codepen for a working example.