Hide and show function not working in Safari

2019-01-29 07:37发布

问题:

This function should stop displaying the #bt_pagamento and start showing the #bt_loading. But Safari (version 6) is the only browser that this function doesn't work. In early versions of Safari (version 5.1.9 Mac and 5.1.7 Win) it worked perfectly.

$("#bt_pagamento").click(function () {
$(this).css({'display':'none'});
$("#bt_loading").show();
});

Does anyone know a work around for this?

回答1:

CSS

<style>
.hide { display: none; }
</style>

HTML

<a href="#" id="bt_pagamento">link</a>
<div id="bt_loading" class="hide">
    this is bt_loading
</div>

JS

$(document).ready(function() {
    $("#bt_pagamento").click(function (e) {
        e.preventDefault();
        $(this).addClass('hide');
        $("#bt_loading").removeClass('hide');
    });
});


回答2:

<script>
jQuery.noConflict()(document).ready(function() {
    $('#hide_value_discount_1').css('disabled','none');
    $('#bt_loading').click()(function(){

        if(document.getElementById('bt_pagamento').click()){
            $('#bt_loading').show('slow');  

        }else
            if(document.getElementById('bt_pagamento').click() == false){
             $('#bt_loading').css('display','none');    

            }

    });
    $('#bt_pagamento').click();
});
</script>


<a href="#" id="bt_pagamento">link</a>
<div id="bt_loading" class="hide">
    this is bt_loading
</div>