Forum Replies Created

Viewing 1 replies (of 1 total)
  • HTML

    <button class="language_selector">Choose Language</button>
    <ul class="languages">
        <li><a href="/en">English</a></li>
        <li><a href="/de">Deutsch</a></li>
    </ul>
    
    <article>
        <h1>More Content</h1>
    </article>
    JavaScript
    
    var trigger = $('.language_selector');
    var list = $('.languages');
    
    trigger.click(function() {
        trigger.toggleClass('active');
        list.slideToggle(200);
    });
    
    // this is optional to close the list while the new page is loading
    list.click(function() {
        trigger.click();
    });
    CSS
    
    .language_selector {
        width: 200px;
        background: #222;
        color:  #eee;
        line-height: 25px;
        font-size: 14px;
        padding: 0 10px;
        cursor: pointer;
    }
    
    .languages {
        display: none;
        position: absolute;
        margin: 0;
        background: #dddddd;
    }
    
    .languages > li {
        width: 200px;
        background: #eee;
        line-height: 25px;
        font-size: 14px;
        padding: 0 10px;
        cursor: pointer;
    }
    
    .languages > li:hover {
        background: #aaa;
    }

    you can consult this code which my friends suggest me. Good luck!

Viewing 1 replies (of 1 total)