0
I have a small problem that I don’t know how to solve, I have a div, that when I click on it it adds something with load(), and keeps alternating this event with toggle(), to add and remove also, only when I give the first click it doesn’t display immediately, only when I click a second time, then it starts to run normally the event click, follows the code:
$('.more .ico').click(function(){
$('.more .toggle').toggle( 50, function(){
$(this).load("frames/menu-drop.php");
});
});
<div class="more">
<div class="ico"></div>
<div class="toggle"></div>
</div>
When you click on the ico, you should load() to . toggle
I understand why this occurs, but I do not know a way to solve, and in case someone suggests using the on('click') I have tried too.
How is HTML? Maybe the problem is in the structure.
– Sam
Already tried with . Trigger('click', Function(){});
– Maycon F. Castro
puts an example of this behavior in jsfiddler or codepen
– RBoschini
I’m gonna try Trigger now
– Breno Castro
With Trigger it is not working... Does not perform the action and no error appears on the console
– Breno Castro
I’ll put the example in codepen
– Breno Castro
But instead of load(), I’ll have to use it to hide the showing with css, but it’s the same thing, it’s the same event, because I’m not only having this problem with it, but when I use on('click') together with toggle and I even understand, I just don’t know how to solve
– Breno Castro
Well put there, only it works normally, I put exactly as it is in mine, but there works normally, but mine does not
– Breno Castro
I believe the problem lies in the fact that it is the load().
– Breno Castro