Streaming live at 10am (PST)

Combine Javascript Code

I use a fantastic 3rd party plugin for playing music and Youtube videos.
The site I have started creating is using a Slider - for which I am using the code in the footer for custom code

	$(document).ready(function() {
		$('#heroslide1').click(function(e) {
			e.preventDefault()
			$('.hero-link').removeClass('active');
			$(this).addClass('active');
			$('.w-slider-nav div:nth-child(1)').trigger('tap');
		});
		$('#heroslide2').click(function(e) {
			e.preventDefault();
			$('.hero-link').removeClass('active');
			$(this).addClass('active');
			$('.w-slider-nav div:nth-child(2)').trigger('tap');
		});
		$('#heroslide3').click(function(e) {
			e.preventDefault();
			$('.hero-link').removeClass('active');
			$(this).addClass('active');
			$('.w-slider-nav div:nth-child(3)').trigger('tap');
		});
		$('#heroslide4').click(function(e) {
			e.preventDefault();
			$('.hero-link').removeClass('active');
			$(this).addClass('active');
			$('.w-slider-nav div:nth-child(4)').trigger('tap');
		});
		$('#heroslide5').click(function(e) {
			e.preventDefault();
			$('.hero-link').removeClass('active');
			$(this).addClass('active');
			$('.w-slider-nav div:nth-child(5)').trigger('tap');
		});
         $('#heroslide6').click(function(e) {
			e.preventDefault();
			$('.hero-link').removeClass('active');
			$(this).addClass('active');
			$('.w-slider-nav div:nth-child(6)').trigger('tap');
		});
	});

I can use API for the audio / video player to stop these playing when a button is clicked

window.onload = function() {
    var anchors = document.getElementsByTagName('*');
    for(var i = 0; i < anchors.length; i++) {
        var anchor = anchors[i];
        anchor.onclick = function() {
            code = this.getAttribute('whenClicked');
            eval(code);   
        }
    }
}

Called using custom attributes on a button:

<a whenClicked=“window[“player1”].loadPlaylist(0)”

However I can only do one or the other - so I can either stop the music OR switch slides not both.
My JS knowledge is limited and I have tried combining the two codes but nothing works.

Any help appreciated.

I’m not 100% following, but maybe try in the window.onload code using document.getElementsByClassName(‘anchor-class’) instead of tag name(’*’).

Hi,
I’ve just re-read what I wrote and it’s wrong … :flushed:
I got mixed up with the code and explained it totally incorrectly.
So I want to be able to add the API call :- window[‘player1’].stop() to the .ready call.
I suspect it should be something similar to

('#heroslide1').click(function(e) { e.preventDefault() (’.hero-link’).removeClass(‘active’);
(this).addClass('active'); (’.w-slider-nav div:nth-child(1)’).trigger(‘tap’);
$window[‘player1’].stop();
});

But this does not work, so I guess it’s incorrect.

Pete