gpt4 book ai didi

jQuery 将标题标签从一个 div 附加到另一个 div

转载 作者:行者123 更新时间:2023-12-01 08:41:59 29 4
gpt4 key购买 nike

我试图从名为 .swatch.selected 的 div 中获取标题属性,并将其移动到我创建的名为 .variationTitle 的新 div 中。我还必须通过 jQuery 附加添加 .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>" );

当您单击跨度图像时,选定的类别会自动添加到跨度标签中。

最佳答案

我认为这应该有效:

http://jsfiddle.net/hHLXr/364/

$('.swatch').click(function() {
var text = $(".swatch").attr("title");
$('.variationTitle').text(text);
});

您基本上获取属性的值并将下一个元素的文本设置为该值。希望它有帮助:)

关于jQuery 将标题标签从一个 div 附加到另一个 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45844891/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com