Grow your CSS skills. Land your dream job.

On body click, hide search

  • # April 21, 2013 at 8:01 am

    @pixelgrid

    Couldn’t I do something like this:

    $(‘.find’).click(function(event) {
    event.preventDefault();
    if ($.browser.msie) {
    $(‘.search’).slideDown(‘slow’);
    }
    else {
    $(‘.search’).slideDown(‘slow’).focus();
    }
    });

    It doesn’t seem to work but you get what I mean.

    # April 21, 2013 at 8:10 am

    sure you can do the sliding effects like that but keep in mind that since jquery 1.9 $.browser is removed.
    So be sure the version you are using is lower than 1.9.Also navigator.userAgent might help you

    actually not slide down but the animate function in my pen

    # April 21, 2013 at 8:27 am

    Hmm. The if/else statement isn’t working for some reason.

    # April 21, 2013 at 10:02 am

    You can maybe try

    if (navigator.appName == ‘Microsoft Internet Explorer’)

    tested on IE9 and IE10. `$.browser` is removed as @pixelgrid said, downgrading your jQuery just to get that back seems not like a valid option to me, though if you did… I’m puzzled why it wouldn’t work.

    # April 21, 2013 at 12:36 pm

    This thread morphed too quickly for me to be able to respond haha.

    My 2c: definitely don’t like the browser sniffing being discussed here, personally.

    Also, you don’t need `e.preventDefault();` on the `.find` click function because it’s not an anchor, so there’s no default functionality you need to override.

    # April 21, 2013 at 12:58 pm

    @TheDoc, I agree on browser sniffing but for this the worst thing that could happen is the input gets focused for future IE versions if they ever decide to go with Netscape as `navigator.appName` like other vendors do.

    # April 22, 2013 at 2:01 am

    Thanks, Gray for pointing that out. I’ll edit the code.

Viewing 7 posts - 16 through 22 (of 22 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".