문제

I have a jplayer on a website, which embeds several playlists. To activate these playlists, I use this function :

jQuery("#playlist_french_baroque").click(function() {
...
});

This works very well.

Now, on other pages on the same website I want to load a specific playlist. This doesn't work because I use the click() function.

What should I do for that ?

Thank you very much.

도움이 되었습니까?

해결책

On your /listen page add this code

$(function () {
    if (window.location.hash) {
        $(window.location.hash).click();
    }
});

This will execute when the page loads, and check if the hash has been set then call the click hander on the element with that hash.

다른 팁

If what you need is to load something without user intervention, you can use the .ready() method provided by jQuery (see docs):

$(document).ready(function() {
  // do whatever you need
});

Which is equivalent to:

$(function() {
 // do whatever you need
});

The code is executed after the DOM is ready.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top