views:

30

answers:

1

Hello,

I'd like to apply a query UI effect to an element depending on the # from the URL.

i.e.: When loading www.mysite.com/page.html#name, effect() is applied to the element with the #name id while loading www.mysite.com/page.html#othername would have effect() apllied to the element with the #othername id and www.mysite.com/page03.html would simply have no effect() applied.

A: 

You can use

window.location.hash to get the part of the URL that follows the # symbol, including the # symbol.

See window.location

In your case it will return #name.

$(function(){
    $("#btn1").click(function(  ){
        var elemName = window.location.hash;
        /* $(elemName) will retrieve the jQuery element with the corresponding 
               id and you can apply the effect to this element.*/
    });
});
rahul
It works like a CharmThanks !
LapinLove404