GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   jquery buffs, question for you (https://gfy.com/showthread.php?t=1035480)

fris 08-24-2011 02:36 PM

jquery buffs, question for you
 
whats the difference between the first function and the 2nd.

Code:

jQuery(document).ready(function($) {
        $('body a').click(function(e) {
                hostname = $(this).prop('hostname');
                hash = $(this).prop('hash');
                if ((window.location.hostname == hostname) && (hash !== '')) {
                        var hash_selector = hash.replace(/([ !"$%&'()*+,.\/:;<=>?@[\]^`{|}~])/g, '\\$1');
                        if ( $( hash_selector ).length > 0 )
                                target = hash;
                        else {
                                anchor = hash;
                                anchor = anchor.replace('#', '');
                                target = 'a[name="' + anchor  + '"]';
                        }
                        e.preventDefault();
                        $('html, body').animate({scrollTop: ($(this.hash)).offset().top}, 400);
                }
        });
});

jQuery(document).ready(function($) {
    $('a[href*=#]').click(function (e) {
        if ($(this.hash).length) {
            e.preventDefault();
            $('html,body').animate({scrollTop: ($(this.hash)).offset().top}, 1000);
        }
    });
});


V_RocKs 08-24-2011 03:38 PM

I could tell you, but then....

Bird 08-24-2011 04:06 PM

top one rewrites <a href="#HASHTAG"> as <a href=" " name="HASHTAG">

while bottom only can see <a href="#HASHTAG">

Probably so the object anchor can be used in another function that is looking for the name tag name=NAMED_ANCHOR

fris 08-24-2011 05:42 PM

Quote:

Originally Posted by Bird (Post 18378152)
top one rewrites <a href="#HASHTAG"> as <a href=" " name="HASHTAG">

while bottom only can see <a href="#HASHTAG">

Probably so the object anchor can be used in another function that is looking for the name tag name=NAMED_ANCHOR

ahh ok, 1st one is what i want then, its for a table of contents where it is labeled

<a href="#1-section-one">1. section one</a>

then when you click that. it goes too

<h3 id="1-section-one">1. section one</h3>


All times are GMT -7. The time now is 08:30 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123