Click here to Skip to main content
15,894,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I got 3 button in main page. Buttons are linked with ID in different page. When i click on button-1 i can get to another pages ID. Inside this ID i have also 3 blocks. If i get here from button-1, i need that block-1 changes css class to be featured.
How to know from witch URL i was comming to change block css?
JavaScript
jQuery(function(){
	jQuery("#block-1").addClass("featured_table")
  })
Posted
Comments
Krunal Rohit 23-Oct-15 7:02am    
So you need to know the previous page URL, right ?

-KR
Member 12081422 23-Oct-15 7:41am    
I need to know which button was clicked on main page, then i will know which block changes class.
Krunal Rohit 23-Oct-15 8:49am    
$("#you-btn-id").click(function() {
// do your stuff...
});

Is it ?
So when you click on button, you'd be redirected to new page, right ?

-KR

1 solution

The easiest option would probably be to use the :target CSS selector[^].

When you link to the second page, specify the target block in the URL:
secondpage.html#block-1

Then apply the styles using the :target selector:
CSS
.block:target
{
    /* Styles for the active block here... */
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900