Results 1 to 4 of 4

Thread: Is there a way to put a link in active state indication with just jquery?

  1. #1
    Join Date
    Jul 2011
    Posts
    40
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Is there a way to put a link in active state indication with just jquery?

    Is there a way to make a page link be activated as in being indicated you are on that page with just javascript or would that be more css?


    For example if I was in HOME it would be indicated with let's say an underline but if I click info when that page loads INFO will be underlined? Can it be done with javascript or just css?

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Can you give us a link to your page and explain with which links and under which circumstances you want this to happen?

    CSS has specific pseudo-classes for links-- for <a> tags. They include :hover :active: and :visited. :hover is applied when the mouse is over the link; :active is applied when you click on a link and it is loading; :visited is applied when the URL is in your history (when you have already been to that page).

    That's as much as CSS can do. Is that what you want?


    Javascript or Jquery could change how a link looks. But you'd need to determine the circumstances for doing this.


    I think what you're looking for is how you can indicate that you are already on a certain section. And then the link to that section will look different than links to other sections.


    This is more often done using a serverside language like PHP. It is possible to do a similar thing using Javascript: you would check the current page's URL and look for any URL that matches the section. Then change the style of that URL as needed. But that is complicated.

    I think it's easier to use PHP to generate all of the links and check at that point to see if one should be formatted in a special way.


    If you want more specific help, post more information.

    For now, see if any of these search results can help:
    http://www.google.com/search?q=navig...nu+active+page

    Both Javascript and PHP options (at least) are included.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jul 2011
    Posts
    40
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Yeah I'm sorry what I meant is indication you are already on a certain section.
    My wording is confusing I apologize for that. I remember learning a while ago however that it can be done with css. I think it was using classes and/or IDs css styling. But PHP and javascript would probably be good as well. I'll look into your link and thanks.

    On a side note where would you recommend me going to learning how to use PHP and mySql/databases?

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You can't use CSS alone because CSS won't know where you are. But you can use CSS to set an "active" style and apply the "active" class to any link/tab you'd like.

    So you would use Javascript to check the current location and see which link/tab it corresponds to.

    Personally I'd use PHP because I build my sites in PHP anyway and it would be easy enough that way. You could do it in JS, but it will be more reliable (and I think a little easier) in PHP.


    I like the tutorial at this site:
    http://php-mysql-tutorial.com

    But I'd recommend learning in general by hands on experience-- start with a small project and build up.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •