0

I have a toggle view content tab with video links inside, it works fine till you click the link to play the video, the video plays but the toggle view closes. How can i make the toggle view to don't close when i click on the links? Also, it is possible to make the first toggle view content tab to be always open when you enter the page? Have no idea about jQuery and can't apply the code properly

$(document).ready(function () {

$('#toggle-view li').click(function () {

    var text = $(this).children('div.panel');

    if (text.is(':hidden')) {
        text.slideDown('200');
        $(this).children('span').html('-');     
    } else {
        text.slideUp('200');
        $(this).children('span').html('+');     
    }
    
});

});

    #toggle-view span {
    position:absolute;
    right:5px; top:0;
    color:#ccc;
    font-size:16px;
}

#toggle-view .panel {
    margin:5px 0;
    display:none;
}
  • put [`e.stopPropagation`](https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation) on your anchor tag click event (I take it the anchor is inside the li?) – Pete Dec 01 '22 at 10:34
  • Can you please share full code to reproduce your functionality? – Kairav Thakar Dec 01 '22 at 10:36
  • Hi yes the anchor is inside the li, i tried $( "#toggle-view li" ).click(function( event ) { event.stopPropagation(); // Do something }); but not work – Anon Nonan Dec 01 '22 at 10:40
  • Well, i had to put div.panel instead of #toggle-view li to prevent it Thanks Pete! – Anon Nonan Dec 01 '22 at 10:46

0 Answers0