1、HTML代碼,如下圖: 2、jQuery代碼,如下圖: ...
1、HTML代碼,如下圖:
<p class="sc_member_recharge_form"> <span class="selected">20元</span> <span >50元</span> <span >100元</span> <span >200元</span> <span >300元</span> <span >其它金額</span> </p>
2、jQuery代碼,如下圖:
<script> $(document).ready(function(){ $(".sc_member_recharge_form span").click(function(){ var select = $(this).text(); if(select === 'other amount' || select === '其它金額'){ $(".sc_member_recharge_form span").removeClass("selected"); $(this).addClass("selected"); }else{ $(".sc_member_recharge_form span").removeClass("selected"); $(this).addClass("selected"); } }); }); </script>