Open In App
Related Articles

jQWidgets jqxTree getSelectedItem() Method

Improve Article
Save Article
Like Article

jQWidgets is a JavaScript framework for making web-based applications for pc and mobile devices. It is a very powerful, optimized, platform-independent, and widely supported framework. The jqxTree represents a jQuery widget that is used to display a hierarchical collection of items. To display the collection of items, we can populate from ‘UL’ or by using its ‘source’ property.

The getSelectedItem() method is used to get the selected item. It does not accept any parameter and returns the object type value.

The returned item has the following fields:

  • label – It specifies the label of item.
  • value – It specifies the value of item.
  • disabled – It specifies whether the item is enabled/disabled.
  • checked – It specifies whether the item is checked/unchecked.
  • element – It specifies the item’s LI tag.
  • parentElement – It specifies the item’s parent LI tag.
  • isExpanded – It specifies whether the item is expanded or collapsed.
  • selected – It specified whether the item is selected or not.


var item = $('Selector').jqxTree('getSelectedItem');


Linked Files: Download jQWidgets from the given link In the HTML file, locate the script files in the downloaded folder.

<link rel=”stylesheet” href=”jqwidgets/styles/jqx.base.css” type=”text/css” />
<script type=”text/javascript” src=”scripts/jquery-1.11.1.min.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqx-all.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxbuttons.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxscrollbar.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxpanel.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxtree.js”></script>

The below example illustrates the jQWidgets jqxTree getSelectedItem() method.



<!DOCTYPE html>
<html lang="en">
    <link rel="stylesheet" href=
    "jqwidgets/styles/jqx.base.css" type="text/css" />
    <script type="text/javascript" 
    <script type="text/javascript" 
    <script type="text/javascript" 
    <script type="text/javascript" 
    <script type="text/javascript" 
    <script type="text/javascript" 
    <script type="text/javascript" 
        h3 {
            text-align: center;
        #jqxTree {
            width: 100%;
            margin: 0 auto;
    <h1 style="color: green;">
        jQWidgets jqxTree getSelectedItem() Method
    <div id='jqxTree'>
            <li item-selected='true'>
            <li id="prog">Programming
            <li>Web Technology
        <input type="button" id="jqxBtn" 
            value="Get Selected Item" 
            style="padding: 5px 15px; margin-top: 20px;">
    <script type="text/javascript">
        $(document).ready(function() {
                width: '350px',
                height: '250px',
                checkboxes: true
        $('#jqxBtn').click(function() {
            var item = $('#jqxTree').jqxTree('getSelectedItem');
            alert("Selected Items: " + item.label);



Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 13 Oct, 2021
Like Article
Save Article
Similar Reads
Complete Tutorials