Solved

Getting value of <li> using JQuery/JS

Posted on 2016-07-20
3
59 Views
Last Modified: 2016-07-20
I am trying to get the whatever option is clicked values inside the <li> starting from "Advanced" all way to "Status" and "Properties" to "ProdSimple" and "Linked Servers" all way to "SDBUsers" and "Paging Analysis" all way to "RepCmp"

  <nav role="navigation" class="navbar navbar-custom">
      <div class="container-fluid">
          <div class="navbar-header">
            <button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
          <a class="navbar-brand" href="#"><img src="images/database_brand.png" alt="Database" /></a>
        </div>
          <div id="navbarCollapse" class="collapse navbar-collapse">
            <ul class="nav navbar-nav">
                <li id="prm_lnk" class="active"><a href="#">Dashboard</a></li>
                                
                <li class="dropdown" > <a href="#" data-toggle="dropdown">Reports <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                      <li class="dropdown-submenu"><a href="#" tabindex="-1" data-toggle="dropdown">Instance</a>
                        <ul  class="dropdown-menu">
                          <li><a href="#" tabindex="-1">Advanced</a></li>
                          <li'><a href="#" tabindex="-1" id ="agent">Agent</a></li>
                          <li><a href="#" tabindex="-1">General</a></li>
                          <li><a href="#" tabindex="-1">ServerConfig</a></li>
                          <li><a href="#" tabindex="-1">Restart</a></li>
                          <li><a href="#" tabindex="-1">Local Date and Time</a></li>
                          <li><a href="#" tabindex="-1">Alerts & Operators</a></li>
                          <li><a href="#" tabindex="-1">Mail Status</a></li>
                          <li><a href="#" tabindex="-1">Status</a></li>

                        </ul>
                      </li>
                      <li class="dropdown-submenu"><a href="#" tabindex="-1" data-toggle="dropdown">Database</a>
                        <ul class="dropdown-menu">
                          <li><a href="#" tabindex="-1">Properties</a></li>
                          <li><a href="#" tabindex="-1">Backup Properties</a></li>
                          <li><a href="#" tabindex="-1">File Properties</a></li>
                          <li><a href="#" tabindex="-1">Partitioning</a></li>
                          <li><a href="#" tabindex="-1">BackupSizes</a></li>
                          <li><a href="#" tabindex="-1">ProdSimple</a></li>
                        </ul>
                      </li>
                       <li class="dropdown-submenu"><a href="#" tabindex="-1" data-toggle="dropdown">Security</a>
                        <ul class="dropdown-menu">
                          <li><a href="#" tabindex="-1">Linked Servers</a></li>
                          <li><a href="#" tabindex="-1">Local Administrators</a></li>
                          <li><a href="#" tabindex="-1">Logins Not Used</a></li>
                          <li><a href="#" tabindex="-1">Orphaned Users</a></li>
                          <li><a href="#" tabindex="-1">SysAdmins</a></li>
                          <li><a href="#" tabindex="-1">ServerRole Members</a></li>
                          <li><a href="#" tabindex="-1">Blank Passwords</a></li>
                          <li><a href="#" tabindex="-1">AgentProxy</a></li>
                          <li><a href="#" tabindex="-1">SLogins</a></li>
                          <li><a href="#" tabindex="-1">SDBUsers</a></li>
                        </ul>
                      </li>
                         <li class="dropdown-submenu"><a href="#" tabindex="-1" data-toggle="dropdown">Logs</a>
                        <ul class="dropdown-menu">
                          <li><a href="#" tabindex="-1">Paging Analysis</a></li>
                          <li><a href="#" tabindex="-1">Paging Details</a></li>
                          <li><a href="#" tabindex="-1">RepCmp</a></li>
                        </ul>
                      </li>
<%--                      <li><a href="#" tabindex="-1">Oracle Reports</a></li>                     --%>
                    </ul>
                  </li>
            </ul> 

Open in new window

0
Comment
Question by:Member_2_7966896
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 15

Assisted Solution

by:Ess Kay
Ess Kay earned 250 total points
ID: 41721638
$("#dropdown-menu li").click(function() {
    alert(this.id); // id of clicked li by directly accessing DOMElement property
    alert($(this).attr('id')); // jQuery's .attr() method, same but more verbose
    alert($(this).html()); // gets innerHTML of clicked li
    alert($(this).text()); // gets text contents of clicked li
});

Open in new window



hope that helps
1
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 250 total points
ID: 41721640
I'm not sure what you are after.  I am going to guess below

http://jsbin.com/bivuhaloni/edit?html,js,output
$(function(){
  
  $('.dropdown-submenu ul.dropdown-menu li').on('click', function(){
    
    alert($(this).text());
    
  });
});

Open in new window

1
 

Author Closing Comment

by:Member_2_7966896
ID: 41721740
Thank you guys! Exactly what I was looking for.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
displaying 3 dropdownlist  horizontally 3 32
Glitching Slide Show 19 27
disable open new tab with right mouse click in <a> tag 3 19
JSON/JQuery/AJAX Error Identification 2 35
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question