【问题标题】:how to add a CSS class inside a JavaScript setup code?如何在 JavaScript 设置代码中添加 CSS 类?
【发布时间】:2014-11-19 14:15:18
【问题描述】:

我需要 JavaScript 帮助。

我有这个滑块脚本:

stepcarousel.setup({
    galleryid: 'mygallery', //id of carousel DIV
    beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
    panelclass: 'panel', //class of panel DIVs each holding content
    autostep: {
        enable:true, 
        moveby:1, 
        pause:3000
    },
    panelbehavior: {
        speed:500, 
        wraparound:false, 
        wrapbehavior:'slide', 
        persist:true
    },
    defaultbuttons: {
        enable: true, 
        moveby: 1, 
        leftnav: ['arl.png', -5, 80], 
        rightnav: ['arr.png', -20, 80]
    },
    statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
    contenttype: ['inline'] //content setting ['inline'] or ['ajax', 'path_to_external_file']
})

我实际上希望defaultbuttons 有一个课程(例如class="defaultbuttons") 因为我无法访问 HTML,因为脚本在“回显”它,我猜是在加载时... 我明白了:

<img src="arl.png" 
     title="Back 1 panels" 
     style="z-index: 50; 
            position: absolute; 
            left: 3px; 
            top: 88px; 
            cursor: pointer; 
            opacity: 1;"
>

我想添加一个简单的类来做进一步的造型。 非常感谢您的帮助;)

【问题讨论】:

  • 你用什么插件?
  • 你好。你说的插件是什么意思?你想要整个 JS 代码还是什么?谢谢!
  • 您发布的代码,它来自哪里?这是您下载并使用的插件吗? plugins.jquery.com/oneStepCarousel如果没有,请提供名称/链接,谢谢
  • 如果您阅读该页面中的文档,您会发现无法将类添加到导航箭头。检查该插件的许可证,如果可以,编辑为箭头附加 html 的 js 代码并在那里硬编码您的类名。
  • 非常感谢,我想出了一种添加 Js 文件的方法。感谢您的提示;)

标签: javascript css class


【解决方案1】:

我明白了。我应该深入研究 js.. 我可以找到这个

<img src="'+config.defaultbuttons.leftnav[0]+'">

那么,问题解决了! 谢谢大家的提示和帮助;)

【讨论】:

    猜你喜欢
    • 2013-06-06
    • 1970-01-01
    • 2022-07-08
    • 2020-03-21
    • 2022-11-24
    • 2016-02-27
    • 2022-01-08
    • 2016-10-16
    • 1970-01-01
    相关资源
    最近更新 更多