Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
320 views
in Technique[技术] by (71.8m points)

javascript - 如何使用jQuery动态更新与materialize.css图像相对应的文本(How to dynamically update text corresponding with materialize.css image using jQuery)

I have a materialize.css carousel that works perfectly.

(我有一个完美工作的materialize.css轮播。)

Next to it, I want to display a description of each image/link using jQuery which is dynamically updated when I slide to the next/previous image in the carousel.

(在它旁边,我想使用jQuery显示每个图像/链接的描述,当我滑动到轮播中的下一个/上一个图像时,它会动态更新。)

I understand how to grab the current image attribute being displayed by the active class.

(我了解如何获取活动类正在显示的当前图像属性。)

$("a.carousel-item.active).attr("itemid") . I can confirm the attribute value is grabbed by console.logging(itemId) . On page load, the first item on the carousel's id is logged to the console. However, when I rotate the carousel, the new id is not being logged.

($("a.carousel-item.active).attr("itemid") 。我可以确认属性值已由console.logging(itemId)抓取。在页面加载时,轮播ID的第一项记录到了但是,当我旋转转盘时,不会记录新的ID。)

  1. How do I make it so that the correct itemId is being grabbed when the active class changes to the next/previous element?

    (我如何做到这一点,以便当活动类更改为下一个/上一个元素时,正确的itemId会被捕获?)

  2. Once I do this, what would be the most efficient way to display the corresponding text?

    (一旦执行此操作,显示相应文本的最有效方法是什么?)

    let itemId = $("a.carousel-item.active").children().attr("itemid")
    console.log("ID: ", itemId)

HTML of active image on carousel in browser

(浏览器中轮播上的活动图片HTML)

  ask by Alexander translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...