I'm working on a web application, Here look at below this jquery codes:
$(document).ready(function () {
var myPlaylist = new jPlayerPlaylist({
jPlayer: "#jplayer_N",
cssSelectorAncestor: "#jp_container_N"
}, [
{
title: "<Here is song title>",
artist: "<here is artist>",
mp3: "Here is song URL", //Here i want to call URL from anchor tag..
poster: "images/m0.jpg"
}
], {
playlistOptions: {
enableRemoveControls: true,
................
................
Now here is my html code, i want to play this music:
<a href="Music/Linkin_park.mp3">Play Linkin park</a>
<a href="Music/Linkin_park2.mp3">Play Linkin park2</a>
<a href="Music/Linkin_park3.mp3">Play Linkin park3</a>
What should i use in this situation?
Did you try the following ?
<a id="lp1" href="Music/Linkin_park.mp3">Play Linkin park</a>
<a id="lp2" href="Music/Linkin_park2.mp3">Play Linkin park2</a>
<a id="lp3" href="Music/Linkin_park3.mp3">Play Linkin park3</a>
And then calling $("#lp1").click();
with a onClick() method for playing each song.
Or maybe you looked for something like this :
var songtoplay = $("#lp1").attr("href");
$(document).ready(function () {
var myPlaylist = new jPlayerPlaylist({
jPlayer: "#jplayer_N",
cssSelectorAncestor: "#jp_container_N"
}, [
{
title: "<Here is song title>",
artist: "<here is artist>",
mp3: songtoplay,
poster: "images/m0.jpg"
}
], {
playlistOptions: {
enableRemoveControls: true,
................
................
You can get an url with the following code $("#identifier").attr("href");
Since I don't know the structure of your application I suggest you do a foreach
through all the a
elements
Please try this
$( "a" ).click(function( event ) {
event.preventDefault();
alert($(this).attr('href'));
});
Hope this be of some help
Happy Learning :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.