Opção jQuery UI Draggable helper
O jQuery UI consiste em widgets GUI, efeitos visuais e temas implementados usando jQuery, CSS e HTML. O jQuery UI é ótimo para construir interfaces de UI para páginas da web. A opção jQuery UI Draggable helper é usada para definir o elemento auxiliar a ser usado para arrastar a exibição.
Sintaxe:
$( ".selector" ).draggable({ helper: "clone" });
Link CDN: Primeiro, adicione os scripts de IU do jQuery necessários para o seu projeto.
<link rel = ”stylesheet” href = ”// code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css”>
<script src = ”// code.jquery.com/jquery- 1.12.4.js ”> </script>
<script src =” // code.jquery.com/ui/1.12.1/jquery-ui.js ”> </script>
Exemplo:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href=
"//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
<script src=
"//code.jquery.com/jquery-1.12.4.js">
</script>
<script src=
"//code.jquery.com/ui/1.12.1/jquery-ui.js">
</script>
<style>
h1 {
color: green;
}
#div_element {
width: 150px;
height: 150px;
background: green;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
}
</style>
</head>
<body>
<h1>GeeksforGeeks</h1>
<h3>jQuery UI Draggable helper Option</h3>
<div id="div_element">Div content</div>
<script>
$(function () {
$("#div_element").draggable({
helper: "clone"
});
});
</script>
</body>
</html>
Saída:
Referência: https://api.jqueryui.com/draggable/#option-helper
As postagens do blog Acervo Lima te ajudaram? Nos ajude a manter o blog no ar!
Faça uma doação para manter o blog funcionando.
70% das doações são no valor de R$ 5,00...
Diógenes Lima da Silva