jeudi 21 juillet 2016

Jquery attr change structure html

i have jquery in there i want to make my structure of my html change when i click my checkbox for example : when i checked my checkbox my .col-md-4 col-md-push-2 will change to .col-md-6 and when i uncheck it will back to normal

here my jquery :

<script src="http://ift.tt/1XwG72U"></script>
<script>
$(document).ready(function(){
    $('input[type="checkbox"]').click(function(){
        $(".col-md-4").attr("class", "col-md-6");
        $(".col-md-push-2").attr("class", "");
    });
});
</script>

and here my view :

<div class="col-md-4 col-md-push-2 space business-fields yes box">
</div>
<div class="col-md-4 col-md-push-2 space business-fields yes box">
</div>

<input type="checkbox" id="try">

in there i can make it change if i check it, but i can't make how to change back again when i uncheck it.

have someone tell me what improvements do i have to make to the code to achieve my goal?




Aucun commentaire:

Enregistrer un commentaire