Foros del Web » Creando para Internet » HTML »

Mover DIV al hacer click!

Estas en el tema de Mover DIV al hacer click! en el foro de HTML en Foros del Web. Hola quisiera saber como puedo hacer para que al hacer click sobre un div el mismo cambie de posición por ejemplo es para un boton ...
  #1 (permalink)  
Antiguo 10/01/2015, 08:15
 
Fecha de Ingreso: noviembre-2014
Mensajes: 6
Antigüedad: 9 años, 6 meses
Puntos: 0
Mover DIV al hacer click!

Hola quisiera saber como puedo hacer para que al hacer click sobre un div el mismo cambie de posición por ejemplo es para un boton de subscribir de youtube.


Yo tengo lo siguiente pero nose que esta mal.



Código:
function funcion()
{        javascript:void(document.getElementById('g-yt').style.margin='140px 140px 140px 140px');
}

Código HTML:
<div class="g-ytsubscribe" id="g-yt" data-channel="CanalYoutube" data-layout="default" data-count="undefined" onclick="funcion()"></div> 
  #2 (permalink)  
Antiguo 10/01/2015, 09:14
Avatar de mbm150  
Fecha de Ingreso: enero-2013
Ubicación: Muskiz
Mensajes: 79
Antigüedad: 11 años, 4 meses
Puntos: 21
Respuesta: Mover DIV al hacer click!

Hola,

Una forma:
Código HTML:
Ver original
  1. <div class="g-ytsubscribe" id="g-yt" data-channel="CanalYoutube" data-layout="default" data-count="undefined" onclick="this.style.margin = '140px';"></div>

Otra:
Código HTML:
Ver original
  1. <div class="g-ytsubscribe" id="g-yt" data-channel="CanalYoutube" data-layout="default" data-count="undefined" onclick="myFunction(this)"></div>
  2. function myFunction(element) {
  3.     element.style.margin = "140px";
  4. }

Saludos.
  #3 (permalink)  
Antiguo 10/01/2015, 09:37
 
Fecha de Ingreso: noviembre-2014
Mensajes: 6
Antigüedad: 9 años, 6 meses
Puntos: 0
Respuesta: Mover DIV al hacer click!

Cita:
Iniciado por mbm150 Ver Mensaje
Hola,

Una forma:
Código HTML:
Ver original
  1. <div class="g-ytsubscribe" id="g-yt" data-channel="CanalYoutube" data-layout="default" data-count="undefined" onclick="this.style.margin = '140px';"></div>

Otra:
Código HTML:
Ver original
  1. <div class="g-ytsubscribe" id="g-yt" data-channel="CanalYoutube" data-layout="default" data-count="undefined" onclick="myFunction(this)"></div>
  2. function myFunction(element) {
  3.     element.style.margin = "140px";
  4. }

Saludos.

Gracias! sirve pero me estoy dando cuenta que al poner el boton de youtube se crea otra div me aparece esto:


Código:
<div id="___ytsubscribe_0" style="text-indent: 0px; margin: -20px; padding: 0px; background: none repeat scroll 0% 0% transparent; border-style: none; float: none; line-height: normal; font-size: 1px; vertical-align: baseline; display: inline-block; width: 116px; height: 24px;"><iframe data-gapiattached="true" src="https://www.youtube.com/subscribe_embed?usegapi=1&amp;count=undefined&amp;layout=default&amp;channel=CanalYoutube&amp;origin=http%3A%2F%2Fmalkiel.com.ar&amp;gsrc=3p&amp;ic=1&amp;jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.es.fklblTu3Z78.O%2Fm%3D__features__%2Fam%3DEQ%2Frt%3Dj%2Fd%3D1%2Ft%3Dzcms%2Frs%3DAGLTcCOK83c4tmj_GDN-HFPAIcVk3K7Qcw#_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart%2Concircled%2Cdrefresh%2Cerefresh%2Conload&amp;id=I0_1420904372064&amp;parent=http%3A%2F%2Fmalkiel.com.ar&amp;pfname=&amp;rpctoken=31189504" name="I0_1420904372064" id="I0_1420904372064" vspace="0" tabindex="0" style="position: static; top: 0px; width: 116px; margin: 0px; border-style: none; left: 0px; visibility: visible; height: 24px;" scrolling="no" marginwidth="0" marginheight="0" hspace="0" frameborder="0" width="100%"></iframe></div>

Osea que lo que haga en el div de youtube no le afecta habria una forma de agregarle lo mismo ?

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:33.