0

我正在尝试在立方体下方显示一个文本....当我独自在小提琴中工作时,代码工作正常....但是当我把它放在我的项目中时它不起作用....你能告诉我如何显示data-text="Cube1"值.....

工作代码http://jsfiddle.net/PKwDp/4/

不工作代码http://jsfiddle.net/rajkumart08/EDKkg/1/

  $('document').ready(function () {
            window.setTimeout(function () {
                $('.cubeCell').each(function () {
                    var htmlText = $(this).attr('data-text');
                    $(this).append('<div class="cubeTextStyle">'+htmlText+'</div>');
                });
            }, 600);

        });


<div  data-text="Cube1" data-caption="&lt;a style='margin-left: 92px; font-size: 18px; color: grey;' href='http://www.w3schools.com/' &gt;Create&lt;/a&gt; &lt;div&gt; &lt;a style='margin-left: 92px; font-size: 18px; color: grey;' &gt;View/Edit&lt;/a&gt; &lt;/div&gt; &lt;a style='margin-left: 92px; font-size: 18px; color: grey;' &gt;Labels&lt;/a&gt;" data-image="http://www.defie.co/designerImages/inventoryControl.png">testing</div>
4

2 回答 2

0

我相信您使用这样的数据属性:

$(this).data('text').val()
于 2013-02-27T21:32:18.540 回答
0

您的(非工作)示例中的问题是具有该data-text属性的元素没有cubeCell类。

这是您在 jsFiddle 中的 HTML:

<div  data-text="Cube1" data-caption="&lt;a style='margin-left: 92px; font-size: 18px; color: grey;' href='http://www.w3schools.com/' &gt;Create&lt;/a&gt; &lt;div&gt; &lt;a style='margin-left: 92px; font-size: 18px; color: grey;' &gt;View/Edit&lt;/a&gt; &lt;/div&gt; &lt;a style='margin-left: 92px; font-size: 18px; color: grey;' &gt;Labels&lt;/a&gt;" data-image="http://www.defie.co/designerImages/inventoryControl.png">testing</div>

编辑:

更新到 jsFiddle 后,现在可以正确添加文本。但是,您看不到它,因为它隐藏在立方体本身的后面。但现在这是一个 CSS 问题,因为您的 CSS 与工作示例完全不同。

编辑2:

您缺少div.cubeTextStyle. 您的工作示例如下:

div.cubeTextStyle {
  position: relative;
  top: 105px;
  background: none !important;
  color: #333 !important;
  border: none !important;
  box-shadow: none !important;
  -webkit-box-shadow: none !important;
}
于 2013-02-27T21:35:00.240 回答