lundi 18 avril 2016

How to fix auto activating checkbox?

$(document).ready(function(){
                if($('.checkbox1').attr('checked') == true) {
                        $(".worddoc").animate({opacity:1},700);
                }
        })
.checkbox1 {
  width: 50px;
  height: 26px;
  position: absolute;
  display: none;
}

.checkbox1:not(checked) + label {
  padding-right: 100%;
  position: relative;
}

.checkbox1:not(checked) + label:after {
  content: '';
  position: absolute;
  top: -4px;
  left: 71%;
  width: 50px;
  height: 26px;
  border-radius: 13px;
  background: #CDD1DA;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  float: right;
}

.checkbox1:not(checked) + label:not(checked):before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 10px;
  background: #FFF;
  left: 73%;
  top: -2px;
  z-index: 998;
  transition: all 0.2s;
  -webkit-transition: all 0.2s;
  -moz-transition: all 0.2s;
  -o-transition: all 0.2s;
  -ms-transition: all 0.2s;
  cursor: pointer;
  float: right;
}

.checkbox1:checked + label:after {
  background: #9FD468;
}

.checkbox1:checked + label:before {
  left: 82%;
}

.label1 {
  color: white;
  font-family: OpenSansRegular;
  font-size: 15px;
  position: absolute;
  float: left;
  top: 30px;
  margin-left: 0;
}

.worddoc {
  width: 40px;
  height: 40px;
  background: orange;
  z-index: 999;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
}
<script src="http://ift.tt/1g1yFpr"></script>
<input type="checkbox" class="checkbox1" id="checkbox1" autocomplete="off"/>
                <label for="checkbox1" class="label1">jQuery</label>
<div class="worddoc"></div>

Hey guys. I want my 1 element appears when checkbox is active, but it gets active right away after loading DOM on website. autocomplete="off" attribute doesn't solve the problem. HELP! I rely on you, guys!




Aucun commentaire:

Enregistrer un commentaire