【问题标题】:Using javascript variavl in jQuery Flip plugin在 jQuery Flip 插件中使用 javascript variavl
【发布时间】:2013-02-17 23:02:51
【问题描述】:

我有这个代码。在“内容”部分,我想要显示一个变量 - currentCard。

这里是代码。非常感谢任何帮助!

 $("#middle").flip({
    direction:'rl',
    content:'currentCard',
    color:'#fff'
})

【问题讨论】:

  • 那不要加引号?
  • 我试过了,还是不行。

标签: javascript jquery html web


【解决方案1】:

奇怪的是,没有引号不适合你,试试这个代码:

var currentCard = "card123";
console.log(currentCard);

$("#middle").flip({
    direction:'rl',
    content:currentCard,
    color:'#fff'
})

要查看控制台输出,请使用浏览器或 Firebug 的开发人员工具。

如果此代码适用于“cart123”,请删除定义 currentCard 的行并保留控制台打印以确保此变量的值与您的想法一致。

【讨论】:

    【解决方案2】:

    你的代码不应该说:

    $("#content").flip({  //changed to 'content' from 'middle'
    direction:'rl',
    content:currentCard, //remove the quotes, because with the quotes, it'll anyway never get the value of the variable.
    color:'#fff'
    });
    

    【讨论】:

    • 另外,请确保您的变量“currentCard”有一个值,并且此代码在运行时可以访问。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-12
    • 1970-01-01
    • 1970-01-01
    • 2020-07-03
    • 2012-09-25
    相关资源
    最近更新 更多