hello what I want it is simply like in the image below : 
 I want if I add #element1 so the div which have the same id ="element1" so it will get colored somehow , I just want to know what to type on google so I can find a solution because I searched for javascript hash etc but without any success.
I want if I add #element1 so the div which have the same id ="element1" so it will get colored somehow , I just want to know what to type on google so I can find a solution because I searched for javascript hash etc but without any success.
            Asked
            
        
        
            Active
            
        
            Viewed 494 times
        
    1
            
            
         
    
    
        Shrinivas Shukla
        
- 4,325
- 2
- 21
- 33
 
    
    
        James sherwod
        
- 21
- 2
- 
                    Are you using the same id more than once? If so, ID's should be unique, hence them being ID's.. to Identify a specific element, not a group of elements. To target a group of elements you should assign them with a class name. – NewToJS Aug 02 '15 at 17:42
- 
                    `$("div#element")` Look for "jQuery selectors". – Vidul Aug 02 '15 at 17:42
- 
                    @Vidul: And the `div` part of that is unnecessary (and slows things down markedly) in 99.999% of use cases. (You only use it when you want the `id` to be ignored if it's not a `div`.) – T.J. Crowder Aug 02 '15 at 17:51
- 
                    1@T.J.Crowder I didn't know this. Thank you. – Vidul Aug 02 '15 at 17:57
2 Answers
0
            
            
        you need to use window.location.hash to get the hash value
so if your hash is #someId23 do something like:
if (window.location.hash){
$(window.location.hash).addClass('selected');
}
 
    
    
        Amir Bar
        
- 3,007
- 2
- 29
- 47
0
            
            
        This answer will help you to focus div, then you can use 'div:focus, div:active' pseudo classes and add some animation there, there are a lot, google it
This is better than jQuery manipulation. Also page performance doesn't affected
 
    
    
        Community
        
- 1
- 1
 
    
    
        Medet Tleukabiluly
        
- 11,662
- 3
- 34
- 69