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

  • Home
  • SEARCH
  • 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 8125929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:58:50+00:00 2026-06-06T06:58:50+00:00

I have a problem with jQuery, I want to change a DIV (not the

  • 0

I have a problem with jQuery, I want to change a DIV (not the content of the DIV but the DIV NAME div id=”DIVNAME”) when the scrollbar is at 20px.

Before scrollbar = 20px :

divname {
width: 1012px;
margin: 25px auto 0 auto;
height: 50px;
}

After scrollbar + 20px :

divname2 {
width: 1012px;
margin: 25px auto 0 auto;
height: 50px;
position: fixed;
}

My specific case :

image http://i.minus.com/jjjWR2hKWhhFw.jpg

Thanks for the help.

  • 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-06T06:58:52+00:00Added an answer on June 6, 2026 at 6:58 am

    You can do this way, like adding a class to the parent div to make it fixed. Will post the code and fiddle shortly.

    Yup done with the code:

    JavaScript

    $(document).ready(function(){
        $(window).scroll(function(){
           if($(".check").offset().top < $(window).scrollTop())
               $(".check").addClass("fixed");
            else
               $(".check").removeClass("fixed"); 
        });
    });​
    

    CSS

    ​ul, ol, p, li {padding: 5px 0;}
    h1 {font: 2em Tahoma bold; text-align: center;}
    div.check.fixed h1 {position: fixed; top: 0; width: 100%; background: #fff;}
    

    HTML

    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
    
    <div class="check">
        <h1>To be fixed!</h1>
    </div>
    
    <ul>
      <li>Coffee</li>
      <li>Tea</li>
      <li>Milk</li>
      <li>Coffee</li>
      <li>Tea</li>
      <li>Milk</li>
    </ul>
    
    <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
    
    <ol>
      <li>Coffee</li>
      <li>Tea</li>
      <li>Milk</li>
      <li>Coffee</li>
      <li>Tea</li>
      <li>Milk</li>
    </ol>
    
    <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
    
    <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</p>​
    

    Fiddle

    Watch it live at http://jsfiddle.net/ekeSL/

    Changing the name of the div

    It is not advisable to change the id of the div. But still if you insist on it, you can do so by this way:

    $("div").attr("id", "newId");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with the jquery-autocomplete pluging and my django script. I want
I have some kind of problem with jQuery selectors. Let's say i want to
I am new to jquery mobile. I have one problem. I want to increase
I have a problem with Jquery function getJSON, the action url does not trigger
It seems I have a problem with JQuery Lite Content Slider. I get a
Hi I have a problem(not exactly problem, I have solved it, but it is
I'm pretty new to Jquery and i want to have a hidden div css:
I have problem while using jquery maskedinput with asp.net textbox. I have a check
I have problem to add jQuery to some existing code, please help. We have
I have some problem with Jquery Autocomplete plugin ( http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/ ) I got it

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.