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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:31:10+00:00 2026-05-30T04:31:10+00:00

It might be that I’ve been staring at this for too long, and the

  • 0

It might be that I’ve been staring at this for too long, and the function I’ve written isn’t really that complicated, but for whatever reason, I cannot get this to function properly. The h1 tag changes as it should, but my if-else doesn’t seem to be functioning based on the “page_layout” variable. My code is below… any ideas?

<script>
    $(document).ready(
     function() {
         //Set text for H1 tags here
         var title = "Test title";

         //Set main-image layout here (1,2,3,4)
         var page_layout = "1";

         //If page_layout = 4, then set connected-image for top
         var connected_image = "images/connected-image.jpg";

         //Image for main-image area
         var main_image = "images/main-image.jpg";

         //Set main-image text here
         var main_image_text = "See how this works.";

         //Set main-image-text-url location
         var main_image_text_url = "http://www.example.com";

         //Do not touch this code
        $('h1').html(title);

        if (page_layout == "1"){
            $.('#main-image').css('background-image', main_image);
            $.('#main-image').css('background-position', 'top right');
            $.('#main-image').css('background-repeat','no-repeat');
            $.('#main-image').addClass('padding-21');
            $.('#main-image').html(main_image_text);
            $.('#main-image').append('<br><a href="' + main_image_text_url + '">tell me more</a>');
        }else if (page_layout == "2"){
            $.('#middle').css('font-size','15px');
            $.('#main-image').addClass('padding-21');
            $.('#main-image').html(main_image_text);
            $.('#main-image').append('<br><a href="' + main_image_text_url + '">tell me more</a>');
        }else if (page_layout == "3"){
            $.('#main-image').css('background-image', main_image);
            $.('#main-image').css('background-position', 'top left');
            $.('#main-image').css('background-repeat','no-repeat');
            $.('#main-image').addClass('padding-491');
            $.('#main-image').html(main_image_text);
            $.('#main-image').append('<br><a href="' + main_image_text_url + '">tell me more</a>');
        }else if (page_layout == "4"){
            $.('connected-image').css('background-image', connected_image );
            $.('connected-image').css('background-position', 'top right');
            $.('connected-image').css('background-repeat','no-repeat');
        }else{
            //Nothing
        }
     }
    )
</script>
  • 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-05-30T04:31:12+00:00Added an answer on May 30, 2026 at 4:31 am

    For starters, you should be seeing some syntax errors in the javascript console. You need to change your selectors from $.('selector') to $('selector') (remove the . after $).

    Also, $('connected-image') should probably be using a class selector $('.connected-image').

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

Sidebar

Related Questions

This seems like something neat that might be built into jQuery but I think
That might be silly question but I really need to know the answer. If
That might be a naive git question but here it is: Before doing a
You might think that this question is already answered. However, I couldn't find the
I have a function that might fail, so the value it returns needs to
I have a file that might contain a line like this. A B //Seperated
The idea is that a game might need something fast but also simplistic. Mainly
That might sound silly but can't do it myself :( Need your help guys.
that might be some kind of a silly question for you guys, but anyways:
Of course you might argue that ASMX is not easier than WCF. But let's

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.