gpt4 book ai didi

javascript:通过函数执行jquery代码变量

转载 作者:行者123 更新时间:2023-11-30 10:43:21 25 4
gpt4 key购买 nike

我不知道好的标题,但这是解释

我有这个链接

<a href="#" class="link" effect="show"> Link1 </a>
<a href="#" class="link" effect="fadeIn"> Link2 </a>
<a href="#" class="link" effect="slideDown"> Link2 </a>

如果点击 .link 我想使用它的效果测量

$('a').hide();
$('.link').click(function(){
var effect = $(this).attr("effect");
/*
what should i do here not conditions to make if effect is show show this link
if its fadeIn do fade in etc

*/
}) ;

最佳答案

这应该有效:

var effect = $(this).attr("effect");
$(this)[effect]();

参见 http://jsfiddle.net/sGWr5/

关于javascript:通过函数执行jquery代码变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9847279/

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