0
I’m starting to study Javascript and Jqueryui am developing the following page:
The problem is that when I click on a new date the old one is not reset as Print below:
I’ve tried everything to create a Reset function, use . remove but nothing works. I’d like some help! Just follow my code:
$(function() {
InciaData();
MostraData();
});
$.datepicker.regional['pt-BR'] = {
closeText: 'Fechar',
prevText: '<Anterior',
nextText: 'Próximo>',
currentText: 'Hoje',
monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho',
'Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun',
'Jul','Ago','Set','Out','Nov','Dez'],
dayNames: ['Domingo','Segunda-feira','Terça-feira','Quarta-feira','Quinta-feira','Sexta-feira','Sabado'],
dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sab'],
dayNamesMin: ['Dom','Seg','Ter','Qua','Qui','Sex','Sab'],
weekHeader: 'Sm',
dateFormat: 'dd/mm/yy',
firstDay: 0,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''
}
function InciaData(){
//passa formato local
$.datepicker.setDefaults($.datepicker.regional['pt-BR']);
//aplica o datepicker
$( "#date" ).datepicker();
$( "#date" ).change( function () {
//alert("ok");
var valor =$("#date").val();
var frase = $(".frase").text();
var n3 = frase+valor;
$(".frase").text(n3).attr('style', 'color:orange;');
});
$(".frase")= $(".frase").val(" ");
}
function MostraData(){
var barra =$( "#mostraData" );
barra.draggable();
}
body{
width: 940px;
margin-right: auto;
margin-left: auto;
}
*{
box-sizing: border-box;
}
.headerTeste{
width: 25.0rem;
height: 15.0rem;
background-image: url(http://www. 88.com.br/assets/img/ 88.svg);
background-repeat: no-repeat;
margin-top: 2em;
margin-right: auto;
margin-left: auto;
}
main p{
font-size: 20px;
font-weight: bold;
}
.ui-widget-header{
background-color: #80e5ff;
color:white;
}
#mostraData{
margin-top: 3rem;
width: 150px;
height: 150px;
padding: 0.5em;
background-color: #66ffcc;
}
.frase{
color:black;
}
#mostraData:hover {
box-shadow: 5px 5px 5px rgba(0,0,0,0.5);
-webkit-transform:scale(1.5);
-mos-transform:scale(1.5);
transform:scale(1.5);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<title>Teste agora</title>
<script src="js/jquery.js"></script>
<link rel="stylesheet" href="css/jquery-ui.min.css">
<link rel="stylesheet" href="css/estiloM2g.css">
<script src="js/jquery-ui.min.js"></script>
<script src="js/scriptJqueryUi.js"></script>
</head>
<body>
<header class="headerTeste">
</header>
<main>
<p>Escolha uma Data:</p>
<input type="text" id="date" name="date">
<div id="mostraData">
<p class="frase">Podem me arrastar: </p>
</div>
</main>
</body>
</html>
Where is the chunk that is cleaning? The reset function or just the same chunk..
– BrTkCa
Lucas Costa, in the function Inciadata().
– Amanda fonseca
Try using this : "var value = $("#date"). val(); $(". phrase"). text("You can drag me: "+value). attr('style', 'color:Orange;');" In the current snippet : "var value =$("#date"). val(); var phrase = $(". phrase"). text(); var N3 = phrase+value; $(". phrase"). text(N3). attr('style', 'color:Orange;');";
– Bruno
Lucas Costa did work, thank you so much for your help :)
– Amanda fonseca