dongliao1949 2013-12-15 12:12
浏览 57
已采纳

如果变量等于,则jquery ajax取消隐藏div

    <script>
$(document).ready(function(){
 var currentsize = $('option:selected', $('select#size')).val();
    $.ajax({
        type: \"post\",
        url: \"tshirt_ajax.php?checkshop=$shopid&checkproducttype=$producttype&stockcolor=\" + $('#productColor$articleid').val() + \"&currentsize=\" + currentsize,
        success: function(data){
            $('select#size').html(data);
   $('#size').coreUISelect();
   $('#quantity').coreUISelect();
  }
    });

   $('a.colorlink').click(function(e){
 e.preventDefault();
    var stockcolor = $(this).attr('id'),
        checkshop = $shopid,
        checkproducttype = $producttype;

    $.ajax({
        type: \"post\",
        url: \"tshirt_ajax.php?checkshop=\" + checkshop + \"&checkproducttype=\" + checkproducttype + \"&stockcolor=\" + stockcolor + \"&currentsize=\" + currentsize,
        beforeSend: function(){
            $('#productColor$articleid').val(stockcolor);
        },
        success: function(data){
            $('select#size').html(data);
        $('#tshirtimg').attr('src', '$http://www.ni-dieu-ni-maitre.com/images/".$productid."_' + stockcolor + '_2/t-shirt-couleur.png');
        $('#ex1 .zoomImg').attr('src', '$http://www.ni-dieu-ni-maitre.com/images/".$productid."_' + stockcolor + '_2/t-shirt-couleur.png');
   $('#size').coreUISelect('update');
        }
    });

    });

 $('select#size').change(function(){
  currentsize = $('option:selected', this).val();
 });

});
</script>

I also have the following div:

<div class='etiquettedescription_content' style='display:none;'>

On the script above, i want to add the following commands:

I'm trying to modify the script above so when "a.colorlink" is clicked, i want to unhide the div but only IF the clicked stockcolor corresponds to 1, 351, 63 OR 16

Any idea how i can do that ?

  • 写回答

2条回答 默认 最新

  • dongnianwo8289 2013-12-15 12:22
    关注

    if i understand your question correctly, then try this:

    $('a.colorlink').click(function(e){
     e.preventDefault();
        var stockcolor = $(this).attr('id'),
            checkshop = $shopid,
            checkproducttype = $producttype;
            if( stockcolor==="1" || stockcolor==="351" stockcolor==="63" stockcolor==="16"  ){
                $(".etiquettedescription_content").show();
            }else{
                $(".etiquettedescription_content").hide();
            }
            .....
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动