Ho bisogno di un tag div per farlo scorrere sul lato destro dello schermo, come faccio a ottenere questo effetto con jQuery? Ho cercato qui: http://api.jquery.com/category/effects/sliding/ e non sembra essere quello che sto cercando ...jQuery .slideEffetto destro
risposta
Se vuoi includere la libreria jQuery UI, oltre a jQuery, puoi semplicemente utilizzare hide()
, with additional arguments, come segue:
$(document).ready(
function(){
$('#slider').click(
function(){
$(this).hide('slide',{direction:'right'},1000);
});
});
Senza usare jQuery UI, si potrebbe raggiungere il tuo obiettivo usando solo animate()
:
$(document).ready(
function(){
$('#slider').click(
function(){
$(this)
.animate(
{
'margin-left':'1000px'
// to move it towards the right and, probably, off-screen.
},1000,
function(){
$(this).slideUp('fast');
// once it's finished moving to the right, just
// removes the the element from the display, you could use
// `remove()` instead, or whatever.
}
);
});
});
Se si sceglie di utilizzare jQuery UI, allora vi consiglio il collegamento al Codice ospitato da Google, al numero: https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js
Sto cercando di stare lontano dall'interfaccia utente jQuery – Webnet
@Webnet, quindi quest'ultimo codice/demo dovrebbe funzionare ... –
Un'altra soluzione è usare .animate() e il CSS appropriato.
ad es.
$('#mydiv').animate({ marginLeft: "100%"} , 4000);
Che non sembra funzionare nel mio esempio .... http : //jsfiddle.net/Webnet/DtzAw/ – Webnet
@Webnet: ma nel [esempio di collegamento a] (http://jsfiddle.net/Webnet/DtzAw/) (nel tuo commento precedente), non apparirà per chiamare ['animate()'] (http://api.jquery.com/animate/). –
Spiacente, non ha collegato la revisione corretta .... http://jsfiddle.net/Webnet/DtzAw/1/ – Webnet
Sfilare lo schermo verso destra, o semplicemente per il bordo destro dello schermo? –
Scivola effettivamente dallo schermo – Webnet