【发布时间】:2023-01-31 02:53:43
【问题描述】:
我在我的网站上使用 Divi 主题生成器。我在文本块中的每个图像下方都放置了标题。标题全部为斜体。谁能告诉我是否可以添加一些 JavaScript 来自动识别字幕行并为其应用 CSS 类?如果这可以自动化就好了,因为手动将 CSS 类添加到每个标题会非常耗时。
这是我正在使用的 HTML:
<div class="dmpro_timeline_item_description">
<p>
<a style="color: inherit;" href="https://path-to-image.jpg">
<img decoding="async" loading="lazy" src="https://path-to-image.jpg" width="300" height="237" alt="" class="wp-image-2179 alignnone size-medium" srcset="https://path-to-image.jpg 300w, https://path-to-image.jpg 1024w, https://path-to-image.jpg 768w, https://path-to-image.jpg 1536w, https://path-to-image.jpg 2048w, https://path-to-image.jpg 15w, https://path-to-image.jpg 1080w, https://path-to-image.jpg 1280w, https://path-to-image.jpg 980w, https://path-to-image.jpg 480w" sizes="(max-width: 300px) 100vw, 300px">
<br>
<em>This is the image caption text.</em>
</a>
</p>
<p>This is where further details go (outside of the caption)</p>
</div>
【问题讨论】:
-
您可以编辑您的问题并包含一个 HTML sn-p(加上您拥有的任何 JavaScript)以便我们可以看到您做了什么吗?
-
如果你的标题可以被识别,那并不复杂。确定的意思是:特定的类,在你的 html 结构中的特定位置......但是你的 html 需要更进一步
-
非常抱歉,完全忘记添加我的 HTML 了!因此,我刚刚编辑了我的问题。目前我没有任何 JavaScript。我应该补充一点,嵌入的图像也可以放置在文本块的下方。因此,这将导致这样的结构 -> 图片、标题、描述性文本、另一张图片、另一张标题、更多描述性文本。
标签: javascript jquery css image divi