Solved

Getting value of <li> using JQuery/JS

Posted on 2016-07-20
3
62 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 53

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

729 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