How can I have a different behavior in this JQuery script if the browser is Chrome?

I am absolutely new in JavaScript and JQuery and I have the following problem.

I have to modify a JQuery script so that it has a different behavior when the browser is Chrome.

This is my script:

$(document).ready(function () {
    $("thead.opening").click(function () {
        alert("INTO second function");
        $(this).next().css('width', '10000000 em');
        alert(modified);
        $(this).next().css('width', '10000000 em');
        $(this).next().css('display', 'table-row-group');
        alert($(this).next().css('display'));
    });
});

As you can see this script perform this statment that sets the display: table-row-group CSS settings:

I want that if the browser is Chrome the script set:

$(this).next().css('display', 'block');

Can I do it in some way?

Answers


You can use:

var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
$(this).next().css('display', is_chrome ? 'block' : 'table-row-group');

Find chrome browser : original post from SO


Need Your Help