Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    dynamically active menu in HTML with javascript

    I have a index.jsp with menu and it has one button, when we click on this button it will open " d.jsp " with same menu ( include menu section in jsp ) page and i have add function which will " active " current menu when we click on one of three menu in index.jsp page as defined below (include jquery)
    now its working fine but my need is : when i will click on button for 'd.jsp' then menu 'c' with 'c.jsp' should be active for 'd.jsp' page . so how can i solve it. Give some suggestions i dont know much about javascript

    1. index.jsp

    Code:
    $('a.tab').each(function(index) {
    if(this.href.trim() == window.location)
    addclass of active from css in jsp at runtime 
    } );
    
    <div class="tab">
      <ul>
        <li><a href="a.jsp" >a</li>
        <li><a href="b.jsp" >b</li>
        <li><a href="c.jsp" >c</li>
      </ul>
    <input type=button onClick(location.href='d.jsp') />

  • #2
    Regular Coder
    Join Date
    Jan 2013
    Location
    Sunnyvale, CA
    Posts
    101
    Thanks
    6
    Thanked 7 Times in 7 Posts
    I do not understand anything about your post.

    Perhaps you can simplify your question?

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,666
    Thanks
    6
    Thanked 1,006 Times in 979 Posts
    Why JavaScript at all? Just do
    Code:
    <div class="tab">
      <ul>
        <li><a href="a.jsp" >a</li>
        <li><a href="b.jsp" >b</li>
        <li class="active"><a href="c.jsp" >c</li>
      </ul>
    or something like that.


  •  

    Posting Permissions

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