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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:18:13+00:00 2026-06-04T20:18:13+00:00

I just started learning jQuery and I’m watching video tutorials and trying to find

  • 0

I just started learning jQuery and I’m watching video tutorials and trying to find different ways to accomplish things than in the video tutorial for learning purposes.

I have two buttons, Day and Night. If I click Day, I want the Day button to be disabled and to load the day style sheet. If I click Night, I want to load the Night stylesheet and disable the Night button, but then enable the Day button.

Bear with me, here’s my code, ihavenoideawhatimdoing.jpg. This isn’t my full code, only posted relevant code.

<head>
    <link rel="stylesheet" href="day.css">
</head>

<button data-file="day">Day</button>
<button data-file="night">Night</button>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<script>

    // self executing function
    (function() {
        var link = $('link');
        var button = $('button');
        var $this = $(this);

        if (button.data('file', 'day').click()) {
            link.attr('href', 'night.css');
            $this.attr('disabled');
            // code to enable night button, not sure how
        }
        else (button.data('file', 'night').click()) {
            link.attr('href', 'day.css');
            $this.attr('disabled');
            // code to enable the day button, not sure how
        }
    })();

</script>

Also, another question.

(function() {
    // code
})();

Will that function execute upon page load, I mean any code within that function? I think the guy in the video called it an autonomous function.

Thanks!

  • 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-04T20:18:15+00:00Added an answer on June 4, 2026 at 8:18 pm
    <head>
        <link rel="stylesheet" href="day.css">
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    </head>
    
    <button id="day" disabled>Day</button>
    <button id="night">Night</button>
    
    <script type="text/javascript">
        $(function() {
            var link = $('link[href="day.css"]'),
                buttons = $('button');
            buttons.on('click', function() {
                link.attr('href', this.id+'.css');
                buttons.not(this).removeAttr('disabled');
                $(this).attr('disabled', 'disabled');
            });
        });
    </script>​
    

    Here’s a fiddle, you can see the stylesheet change in your console.

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

Sidebar

Related Questions

Just started learning Rails (3). I am tearing my hair out trying to find
I just started programming and learning Jquery, I'm trying to build a simple show/hide
I've just started learning Jquery but the examples aren't helping me much... Now whats
I have just started learning Jquery and am new to writing javascript (I am
I´ve just started learning GWT and I´m trying to implement http://gwt.google.com/samples/Showcase/Showcase.html#!CwFileUpload and but failing
I just started learning Common Lisp a few days ago, and I'm trying to
I've just started learning jQuery/javascript, so this might seem like a really basic question,
I started learning jQuery just yesterday, and I like it very much. And now
So I've just started learning jQuery Mobile, and I've learned how it loads all
Question 1 I've just started learning jQuery and one thing that puzzles me is

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.