Reputation: 3223
I want my img link to call a javascript function that will send a name which will be a video.mp4 name to the function sendName. At this point sendName should just display an alert.
In the end I want to call the jwplayer inside of a function that I can send in a parameter with a movie name so that it will play the particular movie. The name valley.mp4 is were the variable will be placed. If I put the jwplayer inside of a function then the player will not load on the screen.
so when I click on a movie name then it will play that movie. This is for my own use at home.
<li class="topfirst"><a href="#" style="width:574px;">
<img src="s/256base-open-over.png" onClick="sendName('a.mp4');">Dr. No. (1962)</a></li>
Other code Here:
jwplayer("test").setup({
playlist: [{
image: "0001.jpg",
sources: [
{file: "valley.mp4",label: "144p"}
]
}]
});
Test function:
function sendName(name) {
alert(name);
}
Upvotes: 0
Views: 1082
Reputation: 2099
You could use data attributes to store params. When the event is fired you the target from event.target and then you could use its data attributes.
// based on jQuery
$('img').on('click', function (event) {
var btn = $(event.target);
sendName(btn.data('video-name'));
});
You should follow similar pattern.
Upvotes: 1