jQuery:查找epubjs结构中的所有p标签

时间:2018-01-30 23:09:29

标签: javascript jquery epub.js

我正在尝试使用epubjs找到通过绘制epub生成的所有p标签。

这是我找到的结构,这里描述的所有元素都有很多类和我可以玩的东西:

<div id="container>
  <div id="epubjs-viewer:random-hash">
    <iframe id="epubjs-iframe:random-hash">
        <!-- body of iframe, has some sections with a few <p>'s inside -->
    </iframe>
  </div>
</div>

有没有简单的方法来访问甚至修改这些内容?我已经尝试了很多选择器但是无法正常工作。

更新

您可以在此处更好地了解结构:http://prntscr.com/i7wr9l

1 个答案:

答案 0 :(得分:0)

在epubjs 0.3中,您可以这样操作:

let book = new ePub.Book(bookPath);
let rendition = new Rendition(book, layoutSettings);
rendition.hooks.content.register((content, rendition) => {
    let pElements = content.document.getElementsByTagName('p');
    //...
});