Uncaught SyntaxError: missing ) after argument list

I’m not sure what’s wrong with this code. I posted it in beautifier.io and there are no red flags. But when I post it on a site, I get the above error:

<script>
        jQuery("#listings .et_pb_blurb_content").append("<div id='sold'>SOLD</div>");
        jQuery(".wppsac-post-title").append("<span class='star-review'><img src='https://viewsstaging.wpengine.com/wp-content/uploads/star-rating.png' alt='five star reviews'></span>");
        jQuery(".gform_button").addClass("et_pb_button");
        jQuery("body.category-blog .more-link").addClass("et_pb_button et_pb_more_button");
</script>

At a glance that code looks ok to me.
Could you point us to a page where we can see the error happening?

Wild guess. If you change the
“append <span><img></span>
to a single <img> element does the error go away?

On what line do you get the error? The error console in your browser will point you to a line, usually with a link that can be clicked to point it out in the code.

This code should post a “SOLD” badge on those images (at least it did before). The browser picks up the error line #111.

$( document ).ready(function() {jQuery("#listings .et_pb_blurb_content").append("<div id='sold'>SOLD</div>");jQuery(".wppsac-post-title").append("<span class='star-review'><img src='https://viewsstaging.wpengine.com/wp-content/uploads/star-rating.png' alt='five star reviews'></span>");jQuery(".gform_button").addClass("et_pb_button");jQuery("body.category-blog .more-link").addClass("et_pb_button et_pb_more_button");});

However, I’m wondering if the error is just being thrown off by a recaptcha error. Testing the code in the browser posts the expected results, so I’m taking a guess about the recaptcha. The recaptcha is assigned the site’s primary domain, so that’s understandable if the error is throwing things off.

is it this class=“lazyload”

append("div id='sold' class="lazyload">SOLD.....

should be class=‘lazyload’ single quotes

2 Likes

That’s probably automated by WordPress. I should get rid of that. It causes a lot of trouble. I’ll get back to you.

1 Like

Yeah. Once I disabled lazyload, the problem went away.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.