<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$( "<input id='myinput' type='text'>" ).appendTo( "body" );
$( "<div id='mytext'></div>" ).appendTo( "body" );
$("#myinput").css({top:0, left: 0,position:'absolute'});
$("#mytext").css({top:50, left: 0,position:'absolute'});
$("#myinput").keyup(function(){
let t = $("#myinput").val();
let my_text ="";
for (let i = 0; i < t.length;i++){
if (i % 2 == 0){
my_text += t.charAt(i).toLowerCase();
}
else{
my_text += t.charAt(i).toUpperCase();
}
}
$("#mytext").text(my_text);
});
});
</script>
</head>
<body>
</body>
</html>
|