spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

One line of JS code is breaking within Wordpress. Not sure why


what you want instead of children, is find. you want to look recursively through all the elements in the jquery object. children is only one level below parent deep. see this fiddle for a toy example http://jsfiddle.net/gq36et5x/1.

instead your code should look like this:

$(function(){
  $(".youtubeThumb").each(function(){
  $(this).bind('click touchstart',
function(event){

    event.preventDefault();

  var ytLink = $(this).find('img').attr('src');
  //the line below is what keeps breaking
  var ytLink =
ytLink.split('/vi/').pop().split('/').shift();
  var ytPlayList =
'PLDMZzXD-QCET2VK_l9aGhOXNMZjWjzI0g';

  $('.youtubeEmbed iframe').attr('src',
'//www.youtube.com/embed/'+ytLink+'?list='+ytPlayList+'&wmode=transparent&autoplay=1');

  $('html, body').animate({
    scrollTop: $('.youtubeEmbed').offset().top
}, 600);
  })
  })
});

also, its not necessary to run the each loop to bind to click event. you could just slim things down this way:

$(function(){
  $(".youtubeThumb").click(function(e){
    e.preventDefault();
    var ytLink, ytPlaylist; 
    ytPlaylist =
'PLDMZzXD-QCET2VK_l9aGhOXNMZjWjzI0g';
    ytLink =
$(this).find('img').attr('src').split('/vi/').pop().split('/').shift();

    $('.youtubeEmbed iframe').attr('src',
'//www.youtube.com/embed/'+ytLink+'?list='+ytPlayList+'&wmode=transparent&autoplay=1');
    $('html, body').animate({ scrollTop:
$('.youtubeEmbed').offset().top}, 600);})
  })
});

Categories : Javascript

Related to : One line of JS code is breaking within Wordpress. Not sure why
c++ breaking up a vector in groups of 7
Sorry I am not c++ fluent, but the logic is here. You can use the modulo and store the two first values of each block: #include <stdio.h> #include <iostream> #include <string.h> using namespace std; int main() { FILE * pFile; char buff [50], value[2][50]; int i=0, j=0; pFile = fopen ("myfile.txt" , "r"); if (pFile == NULL) perror ("Error opening file");

Categories : C++
How to fix “element.dispatchEvent is not a function” without breaking something else?
When you call jQuery.noConflict(); you no longer associate jQuery with the $ variable. So things like $().click or $(selector) will throw errors. Instead, you can do something like this: jQuery.noConflict(); jQuery('a.try').click(handler); jQuery(window).height(); Or, you can also assign jQuery to a new variable, like this: var j$ = jQuery.noConflict(); j$('a.try').click(handler); j$(window).

Categories : Javascript
Mark space for :after content non-breaking
I’m afraid the problem here is that when you set display: inline-block on the pseudo-element, it becomes an element that is treated as external to text (comparable to an image) and may be wrapped into the next line, even when it immediately follows a character. And if you let it default to display: inline, the width property does not apply to it, so it just doesn’t do what you want. But you m

Categories : CSS
Why is Kendo sortable breaking my knockout select?
Silly me. I had to add "select" to the ignore attribute of the sortable. function item(i) { var self = this; self.Type = ko.observable(i.Type || 0); self.Name = ko.observable(i.Name || "New item"); } function itemType(it) { var self = this; self.TypeId = ko.observable(it.TypeId || 0); self.TypeName = ko.observable(it.TypeName || ""); } function ItemViewModel() { var self = thi

Categories : Knockout Js
how to speed up compilation by breaking one C# project into several projects
Firstly 35secs is not that long for a compile of a "large" project. The projects and files in those projects shouldn't be about minimizing compile time, it should be about packaging and managing dependencies. Compile times depend on a lot of things. Solutions with multiple projects can skip the compilation of projects when nothing has changed, however if you change code in a project early in

Categories : C#
Recently Add
Busy Indicator while page is loading
parent.document.getElementById and images path
Can not get bootstrap datetime picker to display properly
reading select box jquery issues
DC.JS Pie Chart + Select Deslect from external JavaScript function
Why would I ever need to cancelAnimationFrame()
Angular.ui alert doesn't close
HTML/JS How to position a rectangle relative to 'any' side of the parent canvas element
parse variable to xml
C# Dictionary equivalent in JavaScript
ExtJS Dashboard Panel Fit Panel Vertically
jQuery cross domain ajax call - Interpreted as script but transferred with MIME type text/xml
Reactjs map returns unexpected token }
Working with multiple pages in apache cordova and vs2013
Resize iframe to loaded content
Why 13596*0.1 is different than 13596/10?
AngularJS Validate all forms on application load
javascript open popup without menu/url/titlebar/scrollbar/anything
Can I use Razor syntax inside Javascript included in a ScriptBundle?
How to show a box for comment reply with id
parse name from user input when using jquery serialize
How to parse and load javascript object?
Marionette not navigating to the same url
Adding Google+ Sign in button to website
GRUNT - Install Grunt Packages?
how should I create the path of templateUrl property in Angular ui-router?
Update mysql database with jquery array using ajax
Run the same function on each item in a list / array
Get all ticks values (NVD3)
Button Click Event not Passing input String to MVC Controller Method
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.