- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚浏览了 jBox.js 的代码,发现了以下代码片段:
var appendImage = function(gallery, id, preload, open) {
if (jQuery('#jBox-image-' + gallery + '-' + id).length) return;
var image = jQuery('<div/>', {
id: 'jBox-image-' + gallery + '-' + id,
'class': 'jBox-image-container'
}).css({
backgroundImage: 'url(' + this.images[gallery][id].src + ')',
backgroundSize: this.options.imageSize,
opacity: (open ? 1 : 0),
zIndex: (preload ? 0 : this.imageZIndex++)
}).appendTo(this.content);
var text = jQuery('<div/>', {
id: 'jBox-image-label-' + gallery + '-' + id,
'class': 'jBox-image-label' + (open ? ' active' : '')
}).html(this.images[gallery][id].label).appendTo(this.imageLabel);
!open && !preload && image.animate({opacity: 1}, this.options.imageFade);
}.bind(this);
现在我的问题与试图访问数组中的某个属性的非常复杂的代码行有关,我正在谈论以下代码行:
this.images[gallery][id].src
上面的行真正试图访问什么样的数组?我已经工作并访问了如下数组:
var s = [{
a : 'name',
b : 'surname'
}];
val = s[0].a; // "name"
console.log(val);
但是我强调的语法似乎有一些额外的层次结构。抱歉,我仍然是一个 javascript 新手,我发现很难想象如何像下面这样访问数组。
this.images[gallery][id].src
看起来像?那么有人可以给我举个例子吗?并解释一下?
谢谢。
最佳答案
gallery, id
可能只是字符串,您可以使用以下属性访问器:
var gallery = 'galleryx',
id = 'idx';
var images = { 'galleryx': { 'idx': 2 } };
console.log(images[gallery][id]) // === 2
关于javascript - 了解 jBox 访问数组中的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31663878/
我正在使用stephanwagner jBox 来完成以下任务。 我有一个列表链接,例如: Delete First Delete Second Delete Third Delete Fourth
我刚刚浏览了 jBox.js 的代码,发现了以下代码片段: var appendImage = function(gallery, id, preload, open) { if (jQuery(
我刚刚试用了这个名为 jBox.js 的插件,发现了一些新选项。这是一个非常可定制的插件。我说的选项是 adjustDistance . documentation说,你可以传入一个整数或对象,像这样
我有这个page (这仍在进行中)其中包含一些图像的缩略图,单击这些缩略图会弹出更大的版本;我正在使用 jBox来完成这个。我正在尝试让更大的图像以响应方式运行。但是什么也做不了! 我通过检查器检查过
当我点击文本框 jbox.js 时显示工具提示,我希望当文本框聚焦时显示工具提示以及当未聚焦时显示工具提示隐藏。 脚本: $(document).ready(function() { $('
我正在使用 jBox 网址:http://stephanwagner.me/jBox . 并在每次点击链接时创建一个模式。首次创建模态时,将在“onCreated”属性上添加该已创建模态上按钮的监听器
这个问题已经有答案了: What does suffix 'f' mean in Java code? (5 个回答) 已关闭 9 年前。 它似乎用在引擎中的值声明中,但 JBox-2D 的文档没有解
快速提问,我在 jBox 中加载 div 时遇到问题(一个简单的 jquery 弹出脚本)。这是我正在使用的代码 $(document).ready(function() { var MJB
我已经搜索了大约 2 个小时,并阅读了方法和教程,但由于某种原因我的程序仍然没有按预期运行。 我想将包含一个包含一些按钮的框的面板放在屏幕中央。有一种方法可以使用 RigidBox 来做到这一点,但它
我是一名优秀的程序员,十分优秀!