【发布时间】:2017-08-23 16:22:27
【问题描述】:
我正在尝试从名为 .swatch.selected 的 div 中获取 title 属性,并将其移动到我创建的名为 .variationTitle 的新 div 中。我还必须通过 jQuery append 添加 .variationTitle 。 这是 HTML 代码:
<div class="tawcvs-swatches" data-attribute_name="attribute_pa_foundation-shades">
<span class="swatch swatch-image swatch-vanilla " title="Vanilla" data-value="vanilla">
<img src="image tag here" alt="Vanilla">
</span>
<div class="variationTitle"></div>
</div>
jQuery:
$( ".tawcvs-swatches" ).append( "<div class='variationTitle'></div>" );
当您单击跨度图像时,已选择的类会自动添加到跨度标记中。
【问题讨论】:
-
那么你想在哪个时钟上附加那个标题?跨度图片点击?
-
.swatch.selected在哪里? -
是的,当您单击 span.swatch 时,该跨度的标题会显示在 .variationTitle 中
-
当您单击 span.swatch 时,会自动添加一类 .selected。这是默认功能的一部分。
-
您是想让
variationTitle的标题与您的.swatch.selected相同,还是想让它作为文本显示给用户?
标签: jquery