Jump to content

[RESOLVED]change color of current link


cinek

Recommended Posts

I have 4 links, each linking to a page, I'm moving around using a next/back button. When the user ends up on page e.g. 4, I want the link 4 to be a different color. How can I do that?the links are generated using php, so adding class active to a link on a page is not an option

Link to comment
Share on other sites

Yeah, active is not for this purpose. It means the user is currently clicking the link.If the page is generated by PHP, then PHP can be told what page is being executed. Have PHP generate the series of links, their text, the tags, everything. Do it in a loop. Grab the data from an array. If a link is not the current page (compare the document names) then use <a> tags or assign the tag a different tag. If a link is the current page, echo the text of the link, but without the <a> tags, or assign it a different class. (I don't know why you think you cannot do that.)

Link to comment
Share on other sites

this is how the link(s) are generated

while($index <= $noOfPages)	{		 $pagination .= '<a '.(($index === $page) ? 'id="this_page"' : '').' href="?page='.$index.'">'.$index.'</a> | ';		 $index++;	}

not sure how I'd do this here

Link to comment
Share on other sites

You've already done it then. In your CSS, just apply the different styling you want for the "this_page" element, which according to your PHP is going to be the current page.In other words, add this:

#this_page {color:red;/*assuming you want "red" to be that other different color*/}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...