I have a side-menu with labels under it define the menu-items and are dynamically generated. When user-clicks on any item, following code must execute:
$("#label").click( function(event) ){
$.get(
"../../phplibraries/productlist.php",
{
ControlName: 'ulCategoryName',
Category: 'Beverages'
},
function(data) {
$('#divList').html(data);
});
});
I am not following how to capture click on any label that is actually a menu item.
— Edited —
The HTML of side menu is as below:
<?php
error_reporting(E_ALL^E_NOTICE);
ini_set('display_errors', '1');
require_once('dbaccess.php');
$ulName = $_GET['ControlName'];
$category = $_GET['Category'];
$result=mysql_query("SELECT pname FROM products WHERE category='".$category."'");
?>
<ul id="<?php echo $ulName; ?>" name="<?php echo $ulName; ?>">
<?php while($row=mysql_fetch_array($result))
{ ?>
<label id="lblCategory" name="lblCategory" style="font-size:medium;"><?php echo $row[1]; ?></label><br />
<!--<li style="font-size:medium;"><?php echo $row[1]; ?></li>-->
<?php } ?>
</ul>
if you need dynamically loaded labels to get the behavior you described consider using jQuery live().
in general, you could define your behavior to certain elements, with the needed selector, when creating the menu, and all dynamically created elements who answer to this selector will gain the same behavior.