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 8095129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:01:14+00:00 2026-06-05T21:01:14+00:00

This should be super simple. The first code block works, but when I wrap

  • 0

This should be super simple. The first code block works, but when I wrap it in a function and attempt to call the function, it doesn’t work.

This Works:

$(document).ready(function() {

        $("#groups-image").hide();
        $("#quiz-image").hide();
        $("#members-image").hide();     

});

This Doesn’t Work:

$(document).ready(function() {

        function hideatstart() {

        $("#groups-image").hide();
        $("#quiz-image").hide();
        $("#members-image").hide();     
        }

        hideatstart();
});

UPDATE: After looking at the accepted answer, I was able to get working code. It involved not having any spaces between the lines of code, which would allow p tags to be inserted. Best practice would be to remove the JQuery to a separate script, which I will do. The following code works:

$(document).ready(function() {
    function hideatstart(){
        $("#groups-image").hide();
        $("#quiz-image").hide();
        $("#members-image").hide();
        }
    hideatstart();
});
  • 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-05T21:01:16+00:00Added an answer on June 5, 2026 at 9:01 pm

    I inspected the HTML on your live site and found that your snippet is outputted like this:

    <div class="art-postcontent">
        <!-- article-content -->
        <!-- [snipped] -->
        <p><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script><br />
    <script type="text/javascript">
        $(document).ready(function() {</p>
    <p>         function hideatstart() {</p>
    <p>         $("#groups-image").hide();
                $("#quiz-image").hide();
                $("#members-image").hide();     
                }</p>
    <p>         hideatstart();
        });
    </script></p>
        <!-- [snipped] -->
    </div>
    

    As you can see, WordPress’s wpautop filter wrapped your lines inside paragraphs.

    If you need to inject a script somewhere, you better do it with a plugin or a theme function and not by pasting the code in a WordPress post or widget. All regular WordPress content types are escaped to prevent such possibly malicious injections. It seems like you’re using a custom art post type, which normally gets a similar treatment. There are ways to prevent the content from being escaped, but you should seriously consider moving your script code somewhere else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seems this should be super simple, but I can't find the right API function
This page I have is super simple, this should be a breeze but I'm
This should be pretty simple, but I can't seem to get it. I have
This should turn out to be a fairly simple Regex, but I'm no expert
This should be so easy... but is driving me mad. UPDATE time SET time
This should be straightforward but I'm getting tripped up on the line inside the
This should be simple - can't figure out where I'm going wrong: We have
This should be a very easy thing to do but I can't find a
This should be simple... class Object: x = 0 y = [] a =
This should be really simple, and I thought I was doing it correctly...evidently not.

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.