I'm totally new to Backbone and JS so forgive me if this is a silly question.
Here is my HTML code:
<div id="sectionOne">
<h3 class="listHeader"></h3>
<ul></ul>
</div>
<div id="sectionTwo">
<h3 class="listHeader"></h3>
<ul></ul>
</div>
<div id="sectionThree">
<h3 class="listHeader"></h3>
<ul></ul>
</div>
If I have a Backbone view where the id refers to sectionOne, for instance, right now I am doing:
$(this.id).append(someCode);
Which works, but of course it only prints within the div. How can I append the code directly to the h3 and ul elements? I tried
$(this.id.ul).append(someCode);
and
$(this.ul).append(someCode);
but neither works. I found a lot of similar questions on here but nothing on how to access elements by tag name within a certain ID.
Thanks!
This is more specifically a jQuery selector question.
$(this.id + ' ul')
will select ul elements nested inside of the div.
$(this.id + ' h3')
will select h3 elements nested inside of the div.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.