简体   繁体   English

我的JavaScript无法加载

[英]My JavaScript won't load

I've been struggling trying to figure it out why my JavaScript code won't run. 我一直在努力弄清楚为什么我的JavaScript代码无法运行。

Can anybody tell me what I missed ? 谁能告诉我我错过了什么? :( :(

JSFiddle JSFiddle

HTML 的HTML

<div class="po-markup">
    <br>
    <a href="#" class="po-link">Hover me </a>
    <div class="po-content hidden">
        <div class="po-title">
            <img src="http://g.etfv.co/http://www.cnn.com" alt="Google" width="16" height="16" />
            Title
        </div> 
        <div class="po-body">
            <p>
                Any Description .... 
            </p>
        </div>
    </div>  
</div>

JS JS JS

you should close }); 您应该关闭});

$(document).ready(function() {

    $('.po-markup > .po-link').popover({
        trigger: 'hover',
        html: true,  // must have if HTML is contained in popover

        // get the title and conent
        title: function() {
            return $(this).parent().find('.po-title').html();
        },
        content: function() {
            return $(this).parent().find('.po-body').html();
        },

        container: 'body',
        placement: 'right'

    });    //add it
});

also you should add bootstrap eg 3.2.0 version 您还应该添加引导程序,例如3.2.0版本

and you should add jquery library in your code eg on onLoad page 并且您应该在代码中添加jquery库,例如在onLoad页面上

this jsfiddle 这个jsfiddle

There are a number of issues with your jsfiddle 您的jsfiddle存在很多问题

  • You aren't referencing jQuery 您不是在引用jQuery
  • You aren't referencing a library that defines popover() 您没有引用定义popover()的库
  • Your Javascript isn't correctly formed; 您的Javascript格式不正确; you need to close the function and call with }); 您需要关闭该函数并使用});调用});

I forked your fiddle and got it to work: http://jsfiddle.net/d2j79z8m/ 我分叉了您的小提琴并使其正常工作: http : //jsfiddle.net/d2j79z8m/

You had a missing }); 您缺少});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM