The script editor web part will not execute in Google Chrome thanks to Chrome's built-in XSS Auditor. This is a feature of Chrome that is designed to mitigate Cross-site Scripting (XSS) attacks.
There are ways to workaround this, but IMO a better solution is to just use JS Link. Upload the script file that you are wanting to run on the page, and then link it using JS Link. I usually place a scripts folder under Site Assets, and that keeps all my scripts in one place, making them easier to manage and update.
Edit: Providing steps for using JS Link.
Step 1: Upload script file(s).
I am using the built in Site Assets Library with a scripts folder that I have added. You can create a new separate library, if you prefer. We just need a place to store the script(s).
In your example, you need to paste the code into a file, make sure you save it with .js extension. Name it whatever you want, and then add it to the library of your choice.
Step 2: Link the script with JS Link.
Once you have the file added, we need to link it to your page. Navigate to the list/page you are wanting to add the script. Click the gear(settings icon) and click on Edit Page. Then select the main web part, and Edit Web Part.
You now have an edit menu on the right side of the page. Scroll to the bottom and expand on the Miscellaneous tab, and see the option for JS Link.
You will paste your file link url in this column. You can paste the full url as
sitename.sharepoint.com/siteassets/scripts/myscript.js OR you can use a shortcut if the folder is on the existing site like this :
~site/siteassets/scripts/myscripts.js. Note, if you are needing to add more than 1 script you can use the pipe character
|. So, if had 2 scripts, my JS Link would look like this
~site/siteassets/scripts/myscript.js | ~site/siteassets/scripts/myscript2.js.
Save your changes and stop editing the page, and you now have successfully linked your scripts.
Did you check the markup of the page after you saved everything? Sometimes it can get stripped out.
Save the page and look at it's source (Ctrl+U) and do a ctrl+f for your snippet.
I found that it interfered with my scripts. You can test if that is the problem by visiting the page directly, so instead of: