Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //forms
- $(document).ready(function(){
- $('.form').each(function(){
- $this = $(this);
- //checkbox
- $checkbox = $this.find('input[type=checkbox]');
- $checkbox.css({
- 'opacity': 0
- });
- value = 0;
- $checkbox_val = $checkbox.is(':checked');
- if($checkbox_val == false) {
- value = '';
- } else {
- value = ' checked';
- }
- $checkbox.wrap( '<span class="input-checkbox'+value+'"></span>' );
- //radio
- $radio = $this.find('input[type=radio]');
- $radio.css({
- 'opacity': 0
- });
- value = 0;
- $radio_val = $radio.is(':checked');
- if($radio_val == false) {
- value = '';
- } else {
- value = ' checked';
- }
- $radio.wrap( '<span class="input-radio'+value+'"></span>' );
- });
- //checkbox actions
- $('.form .input-checkbox').on({
- hover: function() {
- $(this).toggleClass('hover');
- },
- mousedown: function() {
- $(this).toggleClass('active');
- },
- mouseup: function() {
- $(this).toggleClass('active');
- },
- click: function() {
- $(this).toggleClass('checked');
- }
- });
- //radio actions
- $('.form .input-radio').on({
- hover: function() {
- $(this).toggleClass('hover');
- },
- mousedown: function() {
- $(this).toggleClass('active');
- },
- mouseup: function() {
- $(this).toggleClass('active');
- },
- click: function() {
- $input_name = $(this).children().attr('name');
- $('.form [name="'+$input_name+'"]').parent().removeClass('checked');
- $(this).toggleClass('checked');
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement