我尝试执行以下操作,通过使用以下查询更改显示价格和订单的直接链接。
function changepricing() {
jQuery("#monthly").slideToggle();
jQuery("#monthly1").slideToggle();
jQuery("#montly2").slideToggle();
jQuery("#monthly3").slideToggle();
jQuery("#monthly4").slideToggle();
jQuery("#halfyear").slideToggle();
jQuery("#halfyear1").slideToggle();
jQuery("#halfyear2").slideToggle();
jQuery("#halfyear3").slideToggle();
jQuery("#halfyear4").slideToggle();
jQuery("#annual").slideToggle();
jQuery("#annual1").slideToggle();
jQuery("#annual2").slideToggle();
jQuery("#annual3").slideToggle();
jQuery("#annual4").slideToggle();
jQuery("#biannual").slideToggle();
jQuery("#biannual1").slideToggle();
jQuery("#biannual2").slideToggle();
jQuery("#biannual3").slideToggle();
jQuery("#biannual4").slideToggle();
jQuery("#prcmonthly1").slideToggle();
jQuery("#prcmonthly2").slideToggle();
jQuery("#prcmonthly3").slideToggle();
jQuery("#prcmonthly4").slideToggle();
jQuery("#prchalfyear1").slideToggle();
jQuery("#prchalfyear2").slideToggle();
jQuery("#prchalfyear3").slideToggle();
jQuery("#prchalfyear4").slideToggle();
jQuery("#prcannual1").slideToggle();
jQuery("#prcannual2").slideToggle();
jQuery("#prcannual3").slideToggle();
jQuery("#prcannual4").slideToggle();
jQuery("#prcbiannual1").slideToggle();
jQuery("#prcbiannual2").slideToggle();
jQuery("#prcbiannual3").slideToggle();
jQuery("#prcbiannual4").slideToggle();
}
是代码
显示和更改价格:
<li id="monthly" class="pricing_header2" style="display:block;"><a href="#" onclick="changepricing();return false;"><span>1 Month </span></a></li>
<li id="halfyear" class="pricing_header2" style="display:none;"><a href="#" onclick="changepricing();return false;"><span>6 Months </span></a></li>
<li id="annual" class="pricing_header2" style="display:none;"><a href="#" onclick="changepricing();return false;"><span>{$LANG.product_choose_one} </span></a></li>
<li id="biannual" class="pricing_header2" style="display:none;"><a href="#" onclick="changepricing();return false;"><span>{$LANG.product_choose_two} </span></a></li>
显示价格和订单链接:
<li id="monthly1" class="pricing_header2" style="display:block;">€1 <span>/1 mo.</span></li>
<li id="halfyear1" class="pricing_header2" style="display:none;">€2 <span>/6 mos.</span></li>
<li id="annual1" class="pricing_header2" style="display:none;">€3 <span>/One yr.</span></li>
<li id="biannual1" class="pricing_header2" style="display:none;">€4 <span>/Two yrs.</span></li>
<li id="prcmonthly1" class="pricing_footer" style="display:block;"><span><a href="link1" class="pricing_button">{$LANG.product_buy_now}</a></li>
<li id="prchalfyear1" class="pricing_footer" style="display:none;"><span><a href="link2" class="pricing_button">{$LANG.product_buy_now}</a></li>
<li id="prcannual1" class="pricing_footer" style="display:none;"><span><a href="link3" class="pricing_button">{$LANG.product_buy_now}</a></li>
<li id="prcbiannual1" class="pricing_footer" style="display:none;"><span><a href="link4" class="pricing_button">{$LANG.product_buy_now}</a></li>
如果我只使用 2 个产品,上面的代码工作正常,但使用 3 或 4 个产品就不起作用。有人可以帮忙吗?我真的很感激。
谢谢, 曼努埃尔
最佳答案
哇!
我可以建议在可切换项上放置另一个类(例如 <li class='pricing_header2 toggleable'>
)并使用以下 JS 代码:
$('.toggleable').slideToggle();
关于javascript - 用于更改价格和订单链接的 JQUERY 切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9064949/