I'm working on a website that's an online version of a book. There are many versions of this book, so the website uses variable pagination to deal with various editions -- the user chooses his edition and the page numbers appear.
The pages are encoded in HTML tags. So, for example:
text
<span id=ed19xxpgxxx> </span>
text 2
where the id of the span tag is the edition and page number. This is repeated for every page break in every edition.
Now, what I need to do is be able to grab all the ids which start with the edition I'm working with, for example ed1939
. Then I need to get each of the page numbers connected with the ids and insert that page number. What I'm thinking is finding all those strings, cutting the page number information off of them, and then inserting them into the HTML. From my research (1, 2) I think I need to use querySelectorAll
. But I'm not very experienced, and I'm not sure how to do that. All of the reference I've seen so far deals with merely selecting ids with a common starting string, not manipulating them.
The solution in use right now is to use document.getElementById
for every single unique id in a very long if block, which could probably be improved.