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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:38:51+00:00 2026-05-25T03:38:51+00:00

We use scrollto. Code:js $(document).ready(function() { $(a.anchorLink).anchorAnimate() }); jQuery.fn.anchorAnimate = function(settings) { settings =

  • 0

We use scrollto.

Code:js

$(document).ready(function() {
    $("a.anchorLink").anchorAnimate()
});

jQuery.fn.anchorAnimate = function(settings) {

    settings = jQuery.extend({
        speed : 1100
    }, settings);   

    return this.each(function(){
        var caller = this
        $(caller).click(function (event) {  
            event.preventDefault()
            var locationHref = window.location.href
            var elementClick = $(caller).attr("href")

            var destination = $(elementClick).offset().top;
            $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
                window.location.hash = elementClick
            });
            return false;
        })
    })
}

code:html

<a href="#myAnchor" rel="" id="anchor1" class="anchorLink">Add a Comment</a>

Scroll to destination:

<a name="myAnchor" id="myAnchor">Play Nicely</a>

We also use show/hide onclick:

code:html

<a class="nag-details" href="javascript:;">Conditions Apply* &#x25BC;</a>

destination:html

<div id="closeable-nag" style="display:none">
<p>some stuff here</p>
</div>

code:js

jQuery(".nag-details").click(function() {
    jQuery("#closeable-nag").slideToggle(function() {
        if (jQuery(this).is(":visible")) {
            jQuery(".nag-details").text("Conditions Apply* \u25b2");
        } else {
            jQuery(".nag-details").text("Conditions Apply* \u25bc");
        }
    });
});

Ok so here is my question.

Onclick of myanchor link, i want to scroll to and open closeable-nag ( and show the div containg “some stuff here”

Is this dooable ?

I could possibly set up 2 fiddles if need be.

Essentially, these 2 work independantly. So I can click the anchor, and page scrolls to dest. element.
I can also click dest. element and SHOW on slide the hidden content, and close the content.

What I am essentially, looking to do is combine scroll page and OPEN the hidden element ( ie. show )

Any suggestions Please.

  • 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-25T03:38:52+00:00Added an answer on May 25, 2026 at 3:38 am

    Here you go! :

    DEMO FIDDLE

    Code:

    $(document).ready(function() {
    
        $("a.anchorLink").anchorAnimate();
    
     // CRETE A FUNCTION 'cond' like 'condition'   
        function cond(){
            $("#closeable-nag").slideToggle(function() {
                if ($(this).is(":visible") ) {
                    $(".nag-details").text("Conditions Apply* \u25b2");
                } else {
                    $(".nag-details").text("Conditions Apply* \u25bc");
                }
            });
        }
    
        $('#anchor1').click(function(){
            cond();   ///////////// run it on anchor click...
        });  
    
        $(".nag-details").click(function() {
            cond();    //////////// and on him-self!
        });   
    
    });
    

    DEMO without the ‘scrollTo’ plugin

    // CREATE A FUNCTION 'slide' ...like... SLIDE! .D
    function slide(){
        var condPos = $('.nag-details').position().top;    
        $('html, body').animate({ scrollTop: condPos }, 2000);
        return false;
    }
    
    // CRETE A FUNCTION 'cond' like 'condition'   
    function cond() {
        $("#closeable-nag").slideToggle(function() {
            if ($(this).is(":visible")) {
                $(".nag-details").text("Conditions Apply* \u25b2");
            } else {
                $(".nag-details").text("Conditions Apply* \u25bc");
            }
        });
    }
    
    $('#anchor1').click(function() {
        cond();  // Run the condition
        slide(); // and SLIDEEEEE! :)
    });
    $(".nag-details").click(function() {
        cond(); //// run just the condition!
    });
    

    And here is a striped code using ternary operators:

    shortened DEMO with ternary operators (and without the plugin)

    var nag = $(".nag-details"),
        t1 = nag.text("Conditions Apply* \u25b2"),
        t2 = nag.text("Conditions Apply* \u25bc");                  
    function s(){
        var cPos = $('.nag-details').position().top;    
        $('html, body').animate({scrollTop:cPos}, 2000);
    }
    function c() {
        $("#closeable-nag").slideToggle(function() {        
            ( $(this).is(":visible") ) ? (t1) : (t2);
        });
    }
    $('#anchor1').click(function() {
       c();
       s();
    });
    $(".nag-details").click(function(){
       c();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP .NET page where I use jQuery. I used this function
I'm trying to use jQuery.scrollTo plugin with accordion (where one block expands after clicking
When I use jquery's .load() function to load the next pages body it does
I know how to get the scrollTop of a page, I use this simple
use this website a lot but first time posting. My program creates a number
I'm a noob with jQuery and I know about scrollTo, but not quite how
I am trying to use jquery to do an animated scroll from one div
I'm trying to create a function that i can use over and over. I
Got this code from here http://www.irunmywebsite.com/raphael/drawtool2.php . Runs great in IE when I tested
I'm quite new to jquery and can't seem to figure out why my code

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.