Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php code to Apply condition in ul tag

i have a ul and li list.When i click on the UL List then it expands and collapse...

below is my links inside ul and li tag.

<ul class="treeview-menu">
            <li><?php echo $this->Html->link(__('Add Users'), array('controller' => 'Users', 'action' => 'addSubUsers', 'plugin' => false)); ?></li>
            <li><?php echo $this->Html->link(__('List Users'), array('controller' => 'Users', 'action' => 'listSubUsers', 'plugin' => false)); ?></li>
    </ul>

Now i need when i click on the Add Users link the ul tag display like below

 <ul class="treeview-menu" style="display: block;">

i created below code for this...but this is not working......

 <li><?php echo $this->Html->link('Add Users',array('controller'=>'Users','action'=>'addSubUsers','plugin' => false),array('id' => 'myId')); ?></li>

<script type="text/javascript">
$( "#myId" ).click(function() {
  $(".treeview-menu").css("display":"block");
});
</script>
like image 462
kaya new Avatar asked Dec 19 '25 05:12

kaya new


1 Answers

Add script when click "Add User" id:

$( "#adduser" ).click(function() {
  $(".treeview-menu").css("display":"none");
});
like image 149
Developer Avatar answered Dec 20 '25 20:12

Developer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!