因此,我仅在我的JSON数据中添加了两个URL,它们都与一首歌曲相关。

现在,前两个图像具有不同的歌曲,其他图像完全没有任何歌曲。

我想从所有div中获取选定的索引,以便可以使用这样的songDetails[selectedIndex].Song

但是我不知道如何获得点击的选定索引。

那么,如何开始播放与单击的项目相对应的歌曲?



const imageData = [{
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Song": "http://www.orangefreesounds.com/wp-content/uploads/2018/09/Hi-tech-electronic-background-music-120-bpm.mp3",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },

    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Song": "http://www.orangefreesounds.com/wp-content/uploads/2018/04/Relaxing-thinking-time-music.mp3",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    }, {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },

    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    }, {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },

    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    }, {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },

];


function generateTemplate(imageData) {
    return `
    <div class="image-box">
    <p>${imageData.Name}</p>
    <img src="${imageData.Icon}"
    alt="${imageData.Name}"
    style="width:100%"
    onclick="playAudio(imageData, this);">
    </div>`
}

function playAudio(songDetails) {
    let collection = document.getElementsByClassName("image-box")[0].selectedIndex;
    alert(collection);
    let song = new Audio(songDetails.Song);
    song.play();
}

document.getElementById("image-container").innerHTML = `
${imageData.map(generateTemplate).join('')}`

body {
    padding: 0;
    margin: 0;
    background: url("/images/party.jpg");
    background-size: cover;
    /* background: green; */
    display: flex;
    /* new */
    flex-direction: column;
    /* new */
    height: 100vh;
    /* new */

}


#albumImage{
    background: green;
    height: 150px;
    width: 150px;
    margin-left: auto;
    margin-right: auto;
}

#search-div {
    /* position: fixed; */
    flex: 0 0 55px;
    /* adjusted; disabled flex-shrink */
    width: 100%;
    background: #242424;
    /* z-index: 20; */
}

.search-bar {
    border-radius: 50px;
    width: 15%;
    margin-top: 1%;
    margin-left: 42%;
    position: relative;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex-wrap: wrap;
    /* position: relative; */
    min-height: 0;
}

.music-bar {
    background-color: #242424;
    width: 100%;
    height: 80px;
    position: fixed;
}

.media-controls {
    display: flex;
    margin-left: auto;
    margin-right: auto;
    width: 150px;
    text-align: center;
    height: 40%;
    top: 10px;
    position: relative;
}

#mediaControlBar {
    background: #242424;
    height: 10%;
}

.prev-btn {
    font-size: 22px;
    color: rgb(88, 88, 88);
    width: 50%;
    margin-top: 5px;
}

.play-btn {
    color: rgb(88, 88, 88);
    font-size: 28px;
    width: 50%;
}

.play-btn:hover {
    color: rgb(187, 187, 187);
}

.next-btn {
    font-size: 22px;
    color: rgb(88, 88, 88);
    width: 50%;
    margin-top: 5px;
}

#seek-bar {
    width: 50%;
    height: 5px;
    background-color: rgb(78, 78, 78);
    display: flex;
    border-radius: 50px;
    cursor: pointer;
    margin-top: 25px;
    margin-left: auto;
    margin-right: auto;
}

#fill {
    background-color: rgb(129, 129, 129);
    background-color: #FFF;
    border-radius: 20px;
    width: 10%;
}

.image-box {
    width: 300px;
    margin: 20px;
    position: relative;
    vertical-align: top;
    font-family: 'Oswald', sans-serif;
}

.flex-container {
    display: flex;
    flex-wrap: wrap;
    overflow-y: auto;
    justify-content: center;
    /* margin-top: 2%; */
    text-align: center;
    color: white;
}

.flex-container img {
    opacity: 0.5;
}

.flex-container img:hover {
    opacity: 1;
}

@media screen and (max-width: 960px) {
    .search-bar {
        display: flex;
        justify-content: center;
        align-items: center;
        vertical-align: middle;
        margin-left: auto;
        margin-right: auto;
        top: 15%;
        width: 40%;
    }
}

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Images</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" media="screen" href="/css/style.css" />

    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
</head>

<body>

    <link href="https://use.fontawesome.com/releases/v5.4.1/css/all.css" rel="stylesheet" />
    <link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">


    <div id="search-div">
        <input type="text" class="search-bar" id="searchBar">
    </div>

    <div class="container">
        <div class="flex-container" id="image-container">
        </div>
    </div>

    <div class="control-bar" id="mediaControlBar">
        <div class="media-controls">
            <div class="prev-btn">
                <i class="fas fa-angle-double-left"></i>
            </div>
            <div class="play-btn">
                <i class="fas fa-play"></i>
            </div>
            <div class="next-btn">
                <i class="fas fa-angle-double-right"></i>
            </div>
        </div>

        <div id="seek-bar">
            <div id="fill"></div>
            <div id="handle"></div>
        </div>
    </div>

    <script src="/js/data.js"></script>
</body>

</html>

最佳答案

您必须定义自己的索引,并根据该索引通过收藏集中的歌曲编号选择歌曲

function playAudio(songDetails, self) {
  let index = [...self.parentElement.children].indexOf(self)
  let song = new Audio(songDetails[index].Song);


您的点击事件也应该在您的div上

<div class="image-box" onclick="playAudio(imageData, this);">




const imageData = [{
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Song": "http://www.orangefreesounds.com/wp-content/uploads/2018/09/Hi-tech-electronic-background-music-120-bpm.mp3",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },

    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Song": "http://www.orangefreesounds.com/wp-content/uploads/2018/04/Relaxing-thinking-time-music.mp3",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    }, {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },

    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    }, {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },

    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    }, {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },
    {
        "Icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/687px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
        "Name": "Mona Lisa",
        "Painter": "Picasso",
        "Year": "1786"
    },

];


function generateTemplate(imageData) {
    return `
    <div class="image-box"
    onclick="playAudio(imageData, this);">
    <p>${imageData.Name}</p>
    <img src="${imageData.Icon}"
    alt="${imageData.Name}"
    style="width:100%">
    </div>`
}

function playAudio(songDetails, self) {
    let index = [...self.parentElement.children].indexOf(self)
    console.log(index);
    console.log(songDetails);
    let song = new Audio(songDetails[index].Song);
    song.play();
}

document.getElementById("image-container").innerHTML = `
${imageData.map(generateTemplate).join('')}`

body {
    padding: 0;
    margin: 0;
    background: url("/images/party.jpg");
    background-size: cover;
    /* background: green; */
    display: flex;
    /* new */
    flex-direction: column;
    /* new */
    height: 100vh;
    /* new */

}


#albumImage{
    background: green;
    height: 150px;
    width: 150px;
    margin-left: auto;
    margin-right: auto;
}

#search-div {
    /* position: fixed; */
    flex: 0 0 55px;
    /* adjusted; disabled flex-shrink */
    width: 100%;
    background: #242424;
    /* z-index: 20; */
}

.search-bar {
    border-radius: 50px;
    width: 15%;
    margin-top: 1%;
    margin-left: 42%;
    position: relative;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex-wrap: wrap;
    /* position: relative; */
    min-height: 0;
}

.music-bar {
    background-color: #242424;
    width: 100%;
    height: 80px;
    position: fixed;
}

.media-controls {
    display: flex;
    margin-left: auto;
    margin-right: auto;
    width: 150px;
    text-align: center;
    height: 40%;
    top: 10px;
    position: relative;
}

#mediaControlBar {
    background: #242424;
    height: 10%;
}

.prev-btn {
    font-size: 22px;
    color: rgb(88, 88, 88);
    width: 50%;
    margin-top: 5px;
}

.play-btn {
    color: rgb(88, 88, 88);
    font-size: 28px;
    width: 50%;
}

.play-btn:hover {
    color: rgb(187, 187, 187);
}

.next-btn {
    font-size: 22px;
    color: rgb(88, 88, 88);
    width: 50%;
    margin-top: 5px;
}

#seek-bar {
    width: 50%;
    height: 5px;
    background-color: rgb(78, 78, 78);
    display: flex;
    border-radius: 50px;
    cursor: pointer;
    margin-top: 25px;
    margin-left: auto;
    margin-right: auto;
}

#fill {
    background-color: rgb(129, 129, 129);
    background-color: #FFF;
    border-radius: 20px;
    width: 10%;
}

.image-box {
    width: 300px;
    margin: 20px;
    position: relative;
    vertical-align: top;
    font-family: 'Oswald', sans-serif;
}

.flex-container {
    display: flex;
    flex-wrap: wrap;
    overflow-y: auto;
    justify-content: center;
    /* margin-top: 2%; */
    text-align: center;
    color: white;
}

.flex-container img {
    opacity: 0.5;
}

.flex-container img:hover {
    opacity: 1;
}

@media screen and (max-width: 960px) {
    .search-bar {
        display: flex;
        justify-content: center;
        align-items: center;
        vertical-align: middle;
        margin-left: auto;
        margin-right: auto;
        top: 15%;
        width: 40%;
    }
}

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Images</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" media="screen" href="/css/style.css" />

    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
</head>

<body>

    <link href="https://use.fontawesome.com/releases/v5.4.1/css/all.css" rel="stylesheet" />
    <link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">


    <div id="search-div">
        <input type="text" class="search-bar" id="searchBar">
    </div>

    <div class="container">
        <div class="flex-container" id="image-container">
        </div>
    </div>

    <div class="control-bar" id="mediaControlBar">
        <div class="media-controls">
            <div class="prev-btn">
                <i class="fas fa-angle-double-left"></i>
            </div>
            <div class="play-btn">
                <i class="fas fa-play"></i>
            </div>
            <div class="next-btn">
                <i class="fas fa-angle-double-right"></i>
            </div>
        </div>

        <div id="seek-bar">
            <div id="fill"></div>
            <div id="handle"></div>
        </div>
    </div>

    <script src="/js/data.js"></script>
</body>

</html>

关于javascript - 我如何根据单击的图像播放声音,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53103595/

10-11 23:36