Wordpress multi-click feature

I would like to use dynamic content on my pages from WordPress; I would like to change the text of a YouTube video. Both functions work fine, but I cannot get both of them to work

Text function (switchcontent.js)

jQuery(document).ready(function($) {
    $("a").click(function(){
        $('#tekst').text( $(this).attr('data-name'));
    });
});
      

Run codeHide result


YouTube function (video.js)

jQuery(document).ready(function($){
	$('.vid_button').click( function(e){
		e.preventDefault();
		var URL = $(this).attr('href');
		//var htm = '[embed]https://youtu.be/' + URL + '[/embed]';
		var htm = '<iframe width="560" height="315" src="http://www.youtube.com/embed/' + URL + '?wmode=transparent&rel=0&theme=dark&color=red&autoplay=1" frameborder="0" allowfullscreen ></iframe>';
		$('.video_position_size').html(htm);
		return false;
	});
});
      

Run codeHide result


Function.php

add_action( 'wp_enqueue_scripts', 'add_my_script' );
function add_my_script() {
	wp_enqueue_script(
        'your-script', // name your script so that you can attach other scripts and de-register, etc.
        get_template_directory_uri() . '/js/custom/video.js', // this is the location of your script file
        array('jquery') // this array lists the scripts upon which your script depends
    );
    wp_enqueue_script(
        'your-script', // name your script so that you can attach other scripts and de-register, etc.
        get_template_directory_uri() . '/js/custom/switchcontent.js', // this is the location of your script file
        array('jquery') // this array lists the scripts upon which your script depends
    );
}
      

Run codeHide result


+3


source to share





All Articles