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 itemClick event is used to triggered when the user clicks a tree item.
Syntax:
$('Selector').on('itemClick', function (event) { });
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 itemClick event.
Example:
HTML
<!DOCTYPE html>
< html lang = "en" >
< head >
< 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 >
< style >
h1,
h3 {
text-align: center;
}
#jqxTree {
width: 100%;
margin: 0 auto;
}
</ style >
</ head >
< body >
< h1 style = "color: green;" >
GeeksforGeeks
</ h1 >
< h3 >
jQWidgets jqxTree itemClick Event
</ h3 >
< div id = 'jqxTree' >
< ul >
< li item-selected = 'true' >
GeeksforGeeks
</ li >
< li >Programming
< ul >
< li >C</ li >
< li >C++</ li >
< li >Java</ li >
< li >Python</ li >
</ ul >
</ li >
< li >Web Technology
< ul >
< li >HTML</ li >
< li >CSS</ li >
< li >JavaScript</ li >
< li >jQuery</ li >
< li >PHP</ li >
</ ul >
</ li >
</ ul >
</ div >
< script type = "text/javascript" >
$(document).ready(function() {
$('#jqxTree').jqxTree({
width: '350px',
height: '250px',
allowDrag: true,
allowDrop: true
});
});
$('#jqxTree').on('itemClick', function (event) {
alert("Item is Clicked!");
});
</ script >
</ body >
</ html >
|
Output:

Reference: https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxtree/jquery-tree-api.htm
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 :
07 Oct, 2021
Like Article
Save Article