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 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?