filmov
tv
Advanced Custom Checkbox (CSS, jQuery) | Separate Label & Input in Checkbox

Показать описание
We have shared videos about creating custom checkbox design by using only CSS and by using JavaScript already. This is advanced tutorial that makes use of CSS and JavaScript to create custom checkbox design but it's different because input is outside of label. Design that you are going to see in this example is simple but functionality is what i want you to keep your focus at.
This example is different because it has separate label and input field. If we can get input inside label then our job gets easier. Clicking at label will automatically select the input checkbox. But here we have them separate. Now clicking on label will not check checkbox. If you work with Shopify or WordPress, you will have to use plugins. Plugins inject code for checkbox that have separate label and input. So this technique is quite useful. Original input check boxes will be hidden. We will design our own checkbox by using CSS. It will have it's own checked state. Each checkbox has different name. We are not using values here because we don't need values here.
If we want any checkbox 'checked' by default, it should have attribute 'checked' in input field. Part of our functionality is to have an additional class with checkbox class. If we will have a class 'checked' with div containing class 'checkbox', it will show checked state in design and we will have to add checked attribute in relevant input element.
When DOM will be ready we will fire a function called 'customCheckBox'. We will cover click scenario and then another scenario where a checkbox is checked from start. We will check if any checkbox is checked. If yes, we will add checked attribute to input field inside it.
You can design any checkbox by using this technique where input and label are separate.
- Hide CSS Code
- Smooth Scroll with CSS Only
- Lazy Load with Only CSS
- CSS Flex Gap / Easy Flexbox
- CSS Only Custom Radio Buttons and Checkboxes
- Make Videos Responsive
- CSS Flexbox game / Learn Flexbox Easily
More CSS Tutorials:
Thank You!
👍 LIKE VIDEO
👊 SUBSCRIBE
🔔 PRESS BELL ICON
✍️ COMMENT
#jquery #css #webdevelopment #webstylepress #csstutorial #jquerytutorial #html #htmlcss #js #javascript
This example is different because it has separate label and input field. If we can get input inside label then our job gets easier. Clicking at label will automatically select the input checkbox. But here we have them separate. Now clicking on label will not check checkbox. If you work with Shopify or WordPress, you will have to use plugins. Plugins inject code for checkbox that have separate label and input. So this technique is quite useful. Original input check boxes will be hidden. We will design our own checkbox by using CSS. It will have it's own checked state. Each checkbox has different name. We are not using values here because we don't need values here.
If we want any checkbox 'checked' by default, it should have attribute 'checked' in input field. Part of our functionality is to have an additional class with checkbox class. If we will have a class 'checked' with div containing class 'checkbox', it will show checked state in design and we will have to add checked attribute in relevant input element.
When DOM will be ready we will fire a function called 'customCheckBox'. We will cover click scenario and then another scenario where a checkbox is checked from start. We will check if any checkbox is checked. If yes, we will add checked attribute to input field inside it.
You can design any checkbox by using this technique where input and label are separate.
- Hide CSS Code
- Smooth Scroll with CSS Only
- Lazy Load with Only CSS
- CSS Flex Gap / Easy Flexbox
- CSS Only Custom Radio Buttons and Checkboxes
- Make Videos Responsive
- CSS Flexbox game / Learn Flexbox Easily
More CSS Tutorials:
Thank You!
👍 LIKE VIDEO
👊 SUBSCRIBE
🔔 PRESS BELL ICON
✍️ COMMENT
#jquery #css #webdevelopment #webstylepress #csstutorial #jquerytutorial #html #htmlcss #js #javascript
Комментарии