JQuery输出到wordpress html包装器

JQuery输出到wordpress html包装器,jquery,html,wordpress,youtube-api,output,Jquery,Html,Wordpress,Youtube Api,Output,正在尝试调用YouTube API在我的网站上放置视频 我正在使用WordPress,我的jQuery在functions.js文件中 视频加载到页面上,但它们完全位于我的包装之外 我希望它们加载到我页面中的特定div中。 下面是我的jQuery使用YouTubes API调用视频 var playlistId = getParameterByName('playlistid'); jQuery.get("http://gdata.youtube.com/feeds/api/playlist

正在尝试调用YouTube API在我的网站上放置视频

我正在使用WordPress,我的jQuery在functions.js文件中

视频加载到页面上,但它们完全位于我的包装之外

我希望它们加载到我页面中的特定div中。


下面是我的jQuery使用YouTubes API调用视频

var playlistId = getParameterByName('playlistid');

jQuery.get("http://gdata.youtube.com/feeds/api/playlists/" + playlistId + "?v=2&alt=json", function (data) {
    //console.log(data);
    var playlistData = jQuery(data.feed.entry);
    jQuery.each(playlistData, function (index, video) {

        // console.log( video.media$group.yt$videoid);
        jQuery(document.body).append(getVideoHtml(video));
    });
    //console.log(playlistData);
});
//$(document.body).append('hello')

function getVideoHtml(video) {
    title = video.title.$t;
    url = video.content.src;
    views = video.yt$statistics.viewCount;
    dateCreated = video.published.$t;
    videoId = video.media$group.yt$videoid.$t;
    // console.log(videoId);
    videoHtml = "<div id=\"videos\"> \
        <p> \
     <iframe id=\"ytplayer" + videoId + "\" type=\"text/html\" width=\"300\" height=\"250\" \
      src=\"http://www.youtube.com/embed/" + videoId + "?autoplay=0&origin=http://example.com\" \
      frameborder=\"0\"/> \
      </p> \
      <p>" + title + "</p> \
      <p>views:" + views + "</p> \
      <p>date created: " + dateCreated + "</p> \
      </div>";
    return videoHtml;
}

function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
var playlyid=getParameterByName('playlyid');
jQuery.get(“http://gdata.youtube.com/feeds/api/playlists/“+playlid+”?v=2&alt=json”,函数(数据){
//控制台日志(数据);
var playlista=jQuery(data.feed.entry);
jQuery.each(播放数据、函数(索引、视频){
//log(video.media$group.yt$videoid);
jQuery(document.body).append(getVideoHtml(video));
});
//控制台日志(播放数据);
});
//$(document.body).append('hello')
函数getVideoHtml(视频){
title=video.title.$t;
url=video.content.src;
views=video.yt$statistics.viewCount;
dateCreated=video.published.$t;
videoId=video.media$group.yt$videoId.$t;
//控制台日志(videoId);
videoHtml=”\
\
\

\ “+标题+”

\ 视图:“+视图+”

\ 创建日期:“+dateCreated+”

\ "; 返回videoHtml; } 函数getParameterByName(名称){ 名称=名称。替换(/[\[]/,“\\\[”)。替换(/[\]]/,“\\\]”); var regex=new RegExp(“[\\?&]”+name+“=([^&\]*)”, results=regex.exec(location.search); 返回结果==null?”:decodeURIComponent(结果[1]。替换(/\+/g,”); }
这是我的HTML,在这里不多,但这是我想要的视频坐在这里

<div id="video-section">

</div>

这是我得到的结果

<div id="wrapper">
    <div id="main">
        <header>
            <div class="logo">
                <img src="/images/logo.png">
            </div>
            <nav></nav>
        </header>
        <div id="video-section"></div>
        <footer>
            <div class="FooterLogo">
                <img src="/images/logo.png">
            </div>
            <div class="FooterText">
                <p>orem ipsum dolor sit amet, nec ad tota possim. Cu vis autem sonet soluta, sit libris debitis honestatis id. Lorem ipsum dolor sit amet, nec ad tota possim.</p>
                <p>Lorem ipsum dolor sit amet, nec ad tota possim. Cu vis autem sonet soluta, sit libris debitis honestatis id.</p>
            </div>
            <div class="FooterIcon">
                <li>Icon</li>
                <li>Icon</li>
                <li>Icon</li>
            </div>
        </footer>
        <div class="FootersFooter"></div>
        <div id="wpadminbar" class="" role="navigation"></div>
        <script src="http://dopepreview.co.uk/wp-content/themes/The Basis/_/js/functions.js"></script>
    </div>
</div>
<script type="text/javascript" src="http://dopepreview.co.uk/wp-includes/js/admin-bar.min.js?ver=3.8.1"></script>
<script type="text/javascript" src="http://dopepreview.co.uk/wp-content/plugins/contact-form-7/includes/js/jquery.form.min.js?ver=3.46.0-2013.11.21"></script>
<script type="text/javascript" src="http://dopepreview.co.uk/wp-content/plugins/contact-form-7/includes/js/scripts.js?ver=3.6"></script>
<div id="video-section">
    <p>
        <iframe id="ytplayer6-JfrvkX3u8" type="text/html" width="300" height="250" src="http://www.youtube.com/embed/6-JfrvkX3u8?autoplay=0&amp;origin=http://example.com" frameborder="0"></iframe>
    </p>
    <p>Rory Sky Show - Caskey (YMCMB) London Interview &amp; Freestyle</p>
    <p>views:2301</p>
    <p>date created: 2013-05-08T14:56:38.000Z</p>
</div>
<div id="video-section">
    <p>
        <iframe id="ytplayeraajud6ks4z8" type="text/html" width="300" height="250" src="http://www.youtube.com/embed/aajud6ks4z8?autoplay=0&amp;origin=http://example.com" frameborder="0"></iframe>
    </p>
    <p>The Rory Sky Show - Shystie Interview (New Music, Azelia Banks Beef &amp; More)</p>
    <p>views:1947</p>
    <p>date created: 2013-04-15T19:12:49.000Z</p>
</div>
<div id="video-section">
    <p>
        <iframe id="ytplayerRziNXcnMUbw" type="text/html" width="300" height="250" src="http://www.youtube.com/embed/RziNXcnMUbw?autoplay=0&amp;origin=http://example.com" frameborder="0"></iframe>
    </p>
    <p>The Rory Sky Show - Sasha Go Hard interview in London</p>
    <p>views:1002</p>
    <p>date created: 2013-11-12T23:15:18.000Z</p>
</div>

无论是同一天还是同一天。与其他解决方案相比,这是一种自由,是一种权利,是一种义务

这是我的责任。这是一个很好的解决方案,是一个很好的解决方案

  • 图标
  • 图标
  • 图标
  • 罗里天空秀-卡斯基(YMCMB)伦敦采访及;自由泳

    视图:2301

    创建日期:2013-05-08T14:56:38.000Z

    Rory Sky Show-Shystie访谈(新音乐、阿塞拜疆银行牛肉及更多)

    视图:1947

    创建日期:2013-04-15T19:12:49.000Z

    罗里天空秀-萨沙在伦敦接受采访

    视图:1002

    创建日期:2013-11-12T23:15:18.000Z


    这三个视频位于包装的外部。

    是否应该将文档正文更改为“视频部分”

    jQuery("#video-section").append(getVideoHtml(video));