Jquery .show() not working in firefox

后端 未结 4 2072
南旧
南旧 2021-02-14 01:30

I have a problem with the jquery show function in firefox.

Situation: I have loaded a iframe with an aspx page in a popup (fancybox). In that aspx page I have a button

相关标签:
4条回答
  • 2021-02-14 02:07

    I had a similar problem. I did set this in my css:

    body { display: none }
    

    and tried to change this in jQuery:

    $("body").show();
    

    which did not work in Firefox.

    After I changed the HTML to

    <body style="display: none">
    

    and removing the part from CSS I was able to use jQuery show(); flawless

    It seems that the inheritance of css rules does not follow the same routine in Firefox as in IE / Chrome.

    0 讨论(0)
  • 2021-02-14 02:25

    It may be just a side-effect of a js error. It's always worth hitting F12 and seeing if there are any js errors in the console. I had a similar issue where I couldn't figure out why .show() wasn't working on an input that had a style of 'display:none' in Firefox and it turned out I had a badly formed selector which was missing a closing ] and threw an error you don't see, until you open Firebug. Chrome was more tolerant showed the button while Firefox caught the bad selector.

    0 讨论(0)
  • 2021-02-14 02:28

    I had a similar problem and my solution was to do

    $("#psharebutton").css("display", "inline-block");
    

    instead of

    $("#psharebutton").show();
    

    A jquery "show" is identical to setting the display style attribute to "block". I found that I needed "inline-block" for firefox and chrome (I didn't need this for IE). I believe (but have not confirmed) that jquery is smart enough to know what the previous display value is and use that, but in my case I started out with display set to "none" so there was no previous value.

    0 讨论(0)
  • 2021-02-14 02:29

    Just write down like $("#psharebutton").attr('display','') or $("#psharebutton").attr('display','block').

    function dolinkedin(url, title, summary, source) {
            $(".smbutton").addClass("buttonDisabled");
            $("#linklinkedin").removeClass("buttonDisabled");
            $("#psharebutton").attr('display','');
    
            parent.sizeFancybox();
        }
    
    0 讨论(0)
提交回复
热议问题