Posted in html
2647
1:19 am, August 9, 2019
 

toggle div function with chevron up down toggle

showing an example of chevron toggles kinda like a manual accordion

Scripts

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>

CSS


@import url('https://fonts.googleapis.com/css?family=Red+Hat+Display&display=swap');
* {
  font-family: 'Red Hat Display', sans-serif;
}
a {

}
.clickbox {
    border-bottom: 1px solid #ece6ed;
    margin-bottom: 18px;
    padding-bottom: 18px;
    max-width:400px;
    margin:0 auto;
}
.click-target {
  display:none;
}
a.click-title {
  font-size:22px;
  text-decoration:none;
  color:green;
}
.chev_up {
    background: url(data:image/svg+xml;base64,PHN2ZyBhcmlhLWhpZGRlbj0idHJ1ZSIgZm9jdXNhYmxlPSJmYWxzZSIgZGF0YS1wcmVmaXg9ImZhcyIgZGF0YS1pY29uPSJjaGV2cm9uLXVwIiBjbGFzcz0ic3ZnLWlubGluZS0tZmEgZmEtY2hldnJvbi11cCBmYS13LTE0IiByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDQ0OCA1MTIiPjxwYXRoIGZpbGw9ImN1cnJlbnRDb2xvciIgZD0iTTI0MC45NzEgMTMwLjUyNGwxOTQuMzQzIDE5NC4zNDNjOS4zNzMgOS4zNzMgOS4zNzMgMjQuNTY5IDAgMzMuOTQxbC0yMi42NjcgMjIuNjY3Yy05LjM1NyA5LjM1Ny0yNC41MjIgOS4zNzUtMzMuOTAxLjA0TDIyNCAyMjcuNDk1IDY5LjI1NSAzODEuNTE2Yy05LjM3OSA5LjMzNS0yNC41NDQgOS4zMTctMzMuOTAxLS4wNGwtMjIuNjY3LTIyLjY2N2MtOS4zNzMtOS4zNzMtOS4zNzMtMjQuNTY5IDAtMzMuOTQxTDIwNy4wMyAxMzAuNTI1YzkuMzcyLTkuMzczIDI0LjU2OC05LjM3MyAzMy45NDEtLjAwMXoiPjwvcGF0aD48L3N2Zz4=) right center no-repeat;
    display:block;
}
.chev_down {
    background: url(data:image/svg+xml;base64,PHN2ZyBhcmlhLWhpZGRlbj0idHJ1ZSIgZm9jdXNhYmxlPSJmYWxzZSIgZGF0YS1wcmVmaXg9ImZhcyIgZGF0YS1pY29uPSJjaGV2cm9uLWRvd24iIGNsYXNzPSJzdmctaW5saW5lLS1mYSBmYS1jaGV2cm9uLWRvd24gZmEtdy0xNCIgcm9sZT0iaW1nIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0NDggNTEyIj48cGF0aCBmaWxsPSJjdXJyZW50Q29sb3IiIGQ9Ik0yMDcuMDI5IDM4MS40NzZMMTIuNjg2IDE4Ny4xMzJjLTkuMzczLTkuMzczLTkuMzczLTI0LjU2OSAwLTMzLjk0MWwyMi42NjctMjIuNjY3YzkuMzU3LTkuMzU3IDI0LjUyMi05LjM3NSAzMy45MDEtLjA0TDIyNCAyODQuNTA1bDE1NC43NDUtMTU0LjAyMWM5LjM3OS05LjMzNSAyNC41NDQtOS4zMTcgMzMuOTAxLjA0bDIyLjY2NyAyMi42NjdjOS4zNzMgOS4zNzMgOS4zNzMgMjQuNTY5IDAgMzMuOTQxTDI0MC45NzEgMzgxLjQ3NmMtOS4zNzMgOS4zNzItMjQuNTY5IDkuMzcyLTMzLjk0MiAweiI+PC9wYXRoPjwvc3ZnPg==) right center no-repeat;
    display:block;
}

JS


function toggle(div_id) {
  console.log(div_id);
  $(div_id).slideToggle();
  $(div_id + "t").toggleClass("chev_up chev_down");
}

$(document).ready(function() {
  $(".click-title").addClass("chev_up");
});

HTML

<div class="clickbox">
<p><a class="click-title chev_up" id="c1t" onclick="toggle('#c1');" href="#!">A Question</a></p>
<p id="c1" class="click-target">Bacon ipsum dolor amet tri-tip strip steak pork loin turducken burgdoggen cow pork belly swine andouille. Jowl leberkas pig venison chicken sirloin tri-tip spare ribs flank beef pork filet mignon shank. Bacon turducken venison, ground round tenderloin meatball flank shankle pork loin porchetta. Flank brisket beef ribs chuck filet mignon ball tip strip steak shank kevin pastrami pork loin landjaeger salami prosciutto pancetta.</p>
</div>

<div class="clickbox">
<p><a class="click-title chev_up" id="c2t" onclick="toggle('#c2');" href="#!">A Question</a></p>
<p id="c2" class="click-target">Bacon ipsum dolor amet tri-tip strip steak pork loin turducken burgdoggen cow pork belly swine andouille. Jowl leberkas pig venison chicken sirloin tri-tip spare ribs flank beef pork filet mignon shank. Bacon turducken venison, ground round tenderloin meatball flank shankle pork loin porchetta. Flank brisket beef ribs chuck filet mignon ball tip strip steak shank kevin pastrami pork loin landjaeger salami prosciutto pancetta.</p>
</div>

Working Result

A Question

Bacon ipsum dolor amet tri-tip strip steak pork loin turducken burgdoggen cow pork belly swine andouille. Jowl leberkas pig venison chicken sirloin tri-tip spare ribs flank beef pork filet mignon shank. Bacon turducken venison, ground round tenderloin meatball flank shankle pork loin porchetta. Flank brisket beef ribs chuck filet mignon ball tip strip steak shank kevin pastrami pork loin landjaeger salami prosciutto pancetta.

A Question

Bacon ipsum dolor amet tri-tip strip steak pork loin turducken burgdoggen cow pork belly swine andouille. Jowl leberkas pig venison chicken sirloin tri-tip spare ribs flank beef pork filet mignon shank. Bacon turducken venison, ground round tenderloin meatball flank shankle pork loin porchetta. Flank brisket beef ribs chuck filet mignon ball tip strip steak shank kevin pastrami pork loin landjaeger salami prosciutto pancetta.

View Statistics
This Week
83
This Month
364
This Year
725

No Items Found.

Add Comment
Type in a Nick Name here
 
Other Items in html
CSSnowflakes simple snowflakes non-JS snowflakes for your website snowflakes falling body effects HTML how to add an IMAGE! Quick HTML Tutorial HTML How to CENTRE Text Easy! - Quick HTML and CSS Tutorial font awesome spinner loader loading spinner Using the HTML tag details for easy accordions Video different sources on screen sizes video embed html responsive Boots Widget change from widget to cat head and click function pulse map dots codemirror with auto preview window using figcaption and figure for your images a google font like muli - mulish and embed code basic radio checklist - check and item and get its value in a textarea share to twitter html link only linked in share link html only, linkedin, linked-in Facebook HTML for Sharing a Link Footer Design and Redesign Regions of New Zealand - In Dropdown Form content editable p tag with spell check enabled get directions from google maps form embed Common and Uncommon Meta Tag's and Social Meta Tags Input Suggestions using a datalist Add custom symbol to ul li list and align text items using the kbd html tag twitter social sharing meta tags test image url that always changes unsplash placeholder set the amount of lines to show in a textarea field Scroll down indicator css javascript and html a page with two images Aligning Images in TinyMCE or Floating them left and right (code) test page for the custom css 12 grid used on this site easy twitter embed code Custom JS Tabs - No Jquery or Jquery UI scroll to top html css and js hide parts of a form until the 1st item is selected load a youtube video in a fancybox modal add google captcha to enable and disable a form button template for testing and live reloading html files toggle div function with chevron up down toggle Bootstrap Card Formatting HTML and CSS - Header and Footer Applied Accessibility - Tab Index Applied Accessibility - Access Keys Dropdown Box with Searchable Text meta keywords tag meta description tag favicon code meta tag foundation includes cdnjs Form elements New Zealand region list video embed no controls video embed tag
Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
There is no way to happiness. Happiness is the way.
Unknown
Random CSS Property

transform-box

The transform-box CSS property defines the layout box to which the transform and transform-origin properties relate.
transform-box css reference