Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8220227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:27:09+00:00 2026-06-07T13:27:09+00:00

I have a function here that toggles opening/closing a div: function searchAnimate(goTo) { if

  • 0

I have a function here that toggles opening/closing a div:

function searchAnimate(goTo) {
    if (goTo == "open") {
        $("#searchdiv").animate({
            bottom: 2,
            right: 0
        }, 1500);
        document.getElementById("openclosearrow").innerHTML = "<div onclick='searchAnimate('close')' id='openclosearrow'>&harr;</div>";
    }
    if (goTo == "close") {
        $("#searchdiv").animate({
            bottom: -45,
            right: -218
        }, 1500);
        document.getElementById("openclosearrow").innerHTML = "<div onclick='searchAnimate('open')' id='openclosearrow'>&harr;</div>";
    }
}

The error is Uncaught SyntaxError: Unexpected token }. I have tried to fix it many ways, but I guess my eyes are just not working today… Can anyone help? Thx!

P.S. If it helps, I am using Chrome.

EDIT

Here is the HTML code:

<div onclick="searchAnimate('close')" id="openclosearrow">&harr;</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T13:27:11+00:00Added an answer on June 7, 2026 at 1:27 pm

    There are better ways of doing this and the mixing of DOM and jQuery is a bad idea, pick one way so it is standard.

    One issue with your code is the quotes are wrong, they need to be escaped

    "<div onclick=\"searchAnimate('open')\" id='openclosearrow'>&harr;</div>"
    

    The problem here is you are replacing the innerHTML of an element with the same code so it would look like this after the first replace

    <div onclick="searchAnimate('close')" id="openclosearrow"><div onclick="searchAnimate('close')" id="openclosearrow">&harr;</div></div>
    

    I doubt that is what you want.

    What you should do is replace the event handler.

    $("#openclosearrow").off("click").on("click",function(){ searchAnimate('open') });
    

    Better yet is not to replace click handler but to detect the state.

    function searchAnimate() {
        var stateSettings,
            newState,
            elem = $("#searchdiv");
        if (elem.data("state")==="open") {
            newState = "close";
            stateSettings = {
                bottom: 2,
                right: 0
            };
        } else {
            newState = "open";
            stateSettings = {
                bottom: -45,
                right: -218
            }
        }
        elem.data("state",newState).animate(stateSettings, 1500);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div (panel class) on my page that toggles open/closed on the
I have a login form at the bottom of the screen that toggles open
We have system here that uses Java JNI to call a function in a
I have a function that uses the Google Blobstore API, and here's a degenerate
Here's a brief rundown of my issue: I have a JavaScript function that gets
I have the middleware that allows me to check user auth, here is: function
Here's the story... I have a jQuery function that does something, this function is
I have a quick question here. I know that the cakePHP find('first') function returns
Here is the situation. I have some javascript that looks like this: function onSubmit()
I have a button that toggles a DIV layer on and off. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.