0
I have a jquery script that only works after page re-load.
Why does this happen?
My script:
$(document.body).ready(function() {
$('.list').each(function(index){
var topli = $(this).children(":first-child");
topli.click(function(){
var parent = $(this).parent();
var sublis = parent.find(".sub");
if(sublis.is(':visible')){
sublis.slideUp();
topli.find('.fa-arrow-right').removeClass('rotatedown');
}else{
sublis.slideDown();
topli.find('.fa-arrow-right').addClass('rotatedown');
}
})
})
});
My jquery is the first script to be imported; This is the target of my script:
<div>
<ul class="list">
<button id="botaoconf" class="btn btn-amber btn-lg btn-group top" mat-button>
<i class="fa fa-cog iconemenu"></i>
<br>
Configurações <i class="fa fa-arrow-right"></i>
</button>
<li class="sub">
<a class="dropdown-item waves-effect" (click)="verificaPermissao(9, 'confestoque')">
<i class="mr-3 fa fa-archive"></i>Estoque</a>
</li>
<li class="sub">
<a class="dropdown-item waves-effect" (click)="verificaPermissao(10, 'confprecificacao')">
<i class="ml-1 mr-4 fa fa-dollar"></i>Precificação</a>
</li>
</ul>
</div>
It could explain better what you really want to try to do with this code. For example the line $('.list'). each(Function(index).. is of no use in this code.
– LeAndrade
when you click on the button opens the list
– veroneseComS