Javascript Function not working in Salient


This is my first question here, I hope you guys can provide some support on an issue i'm running into with the Salient Theme.

The site i'm working on is

I'm using the image comparison feature, and i'm trying to display three thumbnails of the image comparisor so the user can select a different one. Only one is visible at first, and the idea is to allow users to toggle a different image comparisor, so ie. there's always one visible and the other two are hidden.

I've set this up using some custom javascript, however I can't get the function to work properly - when clicking on one of the thumbnails the page goes dark. I can't figure out what the problem is, so any help in solving this would be greatly appreciated!

If you look at the website it's all pretty self explanatory (i've added a raw js element under the image comparison), but if you need more info please let me know.

Here's the JS

`<script type="text/javascript">
function showonlyone(thechosenone) {
var newboxes = document.getElementsByTagName("div");
for(var x=0; x<newboxes.length; x++) {
name = newboxes[x].getAttribute("class");
if (name == 'newboxes') {
if (newboxes[x].id == thechosenone) {
newboxes[x].style.display = 'block';
else {
newboxes[x].style.display = 'none';

Looking forward to your reply!

Many thanks in advance, Bart

  • Predrag Dubajic

    Hey Bart,

    Hope you're doing well today :slight_smile:

    I'm not much familiar with Salient theme so not sure if I would be of much help here but I'll do my best :slight_smile:

    For starters, can you tell me how is that image comparison section added, is that part of the theme or you've added it via plugin?

    When I check your page I see there's a console error:
    Uncaught Error: Syntax error, unrecognized expression: div#/

    So if there's some script breaking on your site it would cause other scripts to fail as well.
    Can you try removing your custom script and see if the console error is still there after that?
    This will tell is if the issue is within that custom script itself or if the error is still there that means that there's something failing previous to that and that needs to be looked in first.

    Let us know how it goes.

    Best regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.