How to move div with jquery

-2

I have this button:

<button onclick="$('#settings, #instructions').toggle(); return false;" class="btn btn-info btn-settings" id="settings-btn"><i class="glyphicon glyphicon-cog"></i></button>

and a div #yt

and I want to achieve with jquery that by pressing the button the div and t go down 10% in css but I can not achieve it, someone would teach me and explain to learn? , thank you

    
asked by Eduardo Campos 12.02.2017 в 20:01
source

1 answer

2

var porcentaje=10;


$('#settings-btn').click(function(){ 
porcentaje+=10;
  $("#yt").css("margin-top", porcentaje+"%"); 
}); 
#yt{
  width: 200px;
  height: 200px;
  background:red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="yt"></div>


<button onclick="$('#settings, #instructions').toggle(); return false;" class="btn btn-info btn-settings" id="settings-btn"><i class="glyphicon glyphicon-cog"></i>insertar</button>
    
answered by 12.02.2017 / 20:22
source