How can I have a different behaviour 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 behaviour 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');
    $(this).next().css('width', '10000000 em');
    $(this).next().css('display', 'table-row-group');

As you can see this script perform this statement 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?


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

How to sort by most viewed in Magento?

magento sorting categories product

In Magento 1.7 i am trying sort product by most viewed product but not successfully done

Exporting data from database to xml

php mysql xml export-to-xml

I need to save data from a relational database record set in MySQL (composed of multiple tables and multiple sub-records for each master record) to an xml file. My questions are: