gpt4 book ai didi

javascript - Jquery 属性值marge

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

我正在尝试将 span 属性中的属性添加到 anchor 的 href 中。它覆盖现有的 href 即 callto:值(value)。我希望它像这样附加 <a class="phone" href="callto:000-555-6666"></a> 。我怎样才能做到这一点?谢谢!

HTML

<a class="phone" href="callto:"></a>
<span class="path" phone="000-555-6666">Test</span>

JQuery

jQuery(".path").mousemove(function(e) {
jQuery(".phone").attr('href', jQuery(this).attr('phone')).attr(jQuery(this).attr('phone'));
});

最佳答案

您正在替换现有值。添加带有电话属性值的“调用:”,然后设置 href 属性。

jQuery(".path").mousemove(function(e) {
jQuery(".phone").attr('href',"callto:"+ jQuery(this).attr('phone'));
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a class="phone" href="callto:"></a>
<span class="path" phone="000-555-6666">Test</span>

关于javascript - Jquery 属性值marge,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50753499/

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