Я пытаюсь заставить мою программу автоматически вычислять функцию, пока пользователь вводит значения c. По какой-то причине функция .keyup не распознается.
Я даже пытался добавить функцию Alert () только для того, чтобы проверить, выполнялась ли она. это к событию keyup , но безрезультатно. И, повозившись, я не мог понять, почему он не работает.
Код ниже ... Пожалуйста, извините за чрезмерное количество кода css, я добавил его только для соответствия.
$(document).ready(function() {
// var value = $("#inputID").val();
// input formatting
$('.amount').mask('#,###.##', {
reverse: true
});
var bal = $('#balance').val();
var daily = $('#percentage').val();
var ppd = $('#pips').val();
var lotsize = (bal * daily) / ppd;
$('.entry').keyup(
function() {
$('#LotSize').val(lotsize);
});
});
=====LEVEL 1. RESET STYLES=====*/ .field {
--uiFieldPlaceholderColor: var(--fieldPlaceholderColor, #767676);
}
.field__input {
background-color: transparent;
border-radius: 0;
border: none;
-webkit-appearance: none;
-moz-appearance: none;
font-family: inherit;
font-size: 1em;
}
.field__input:focus::-webkit-input-placeholder {
color: var(--uiFieldPlaceholderColor);
}
.field__input:focus::-moz-placeholder {
color: var(--uiFieldPlaceholderColor);
opacity: 1;
}
/*
=====
LEVEL 2. CORE STYLES
=====
*/
.a-field {
display: inline-block;
}
.a-field__input {
display: block;
box-sizing: border-box;
width: 100%;
}
.a-field__input:focus {
outline: none;
}
/*
=====
LEVEL 3. PRESENTATION STYLES
=====
*/
/* a-field */
.a-field {
--uiFieldHeight: var(--fieldHeight, 40px);
--uiFieldBorderWidth: var(--fieldBorderWidth, 2px);
--uiFieldBorderColor: var(--fieldBorderColor);
--uiFieldFontSize: var(--fieldFontSize, 1em);
--uiFieldHintFontSize: var(--fieldHintFontSize, 1em);
--uiFieldPaddingRight: var(--fieldPaddingRight, 15px);
--uiFieldPaddingBottom: var(--fieldPaddingBottom, 15px);
--uiFieldPaddingLeft: var(--fieldPaddingLeft, 15px);
position: relative;
box-sizing: border-box;
font-size: var(--uiFieldFontSize);
padding-top: 1em;
}
.a-field__input {
height: var(--uiFieldHeight);
padding: 0 var(--uiFieldPaddingRight) 0 var(--uiFieldPaddingLeft);
border-bottom: var(--uiFieldBorderWidth) solid var(--uiFieldBorderColor);
}
.a-field__input::-webkit-input-placeholder {
opacity: 0;
transition: opacity .2s ease-out;
}
.a-field__input::-moz-placeholder {
opacity: 0;
transition: opacity .2s ease-out;
}
.a-field__input:not(:placeholder-shown)~.a-field__label-wrap .a-field__label {
opacity: 0;
bottom: var(--uiFieldPaddingBottom);
}
.a-field__input:focus::-webkit-input-placeholder {
opacity: 1;
transition-delay: .2s;
}
.a-field__input:focus::-moz-placeholder {
opacity: 1;
transition-delay: .2s;
}
.a-field__label-wrap {
box-sizing: border-box;
width: 100%;
height: var(--uiFieldHeight);
pointer-events: none;
cursor: text;
position: absolute;
bottom: 0;
left: 0;
}
.a-field__label {
position: absolute;
left: var(--uiFieldPaddingLeft);
bottom: calc(50% - .5em);
line-height: 1;
font-size: var(--uiFieldHintFontSize);
pointer-events: none;
transition: bottom .2s cubic-bezier(0.9, -0.15, 0.1, 1.15), opacity .2s ease-out;
will-change: bottom, opacity;
}
.a-field__input:focus~.a-field__label-wrap .a-field__label {
opacity: 1;
bottom: var(--uiFieldHeight);
}
/* a-field_a1 */
.a-field_a1 .a-field__input {
transition: border-color .2s ease-out;
will-change: border-color;
}
.a-field_a1 .a-field__input:focus {
border-color: var(--fieldBorderColorActive);
}
/* a-field_a2 */
.a-field_a2 .a-field__label-wrap::after {
content: "";
box-sizing: border-box;
width: 0;
height: var(--uiFieldBorderWidth);
background-color: var(--fieldBorderColorActive);
position: absolute;
bottom: 0;
left: 0;
will-change: width;
transition: width .285s ease-out;
}
.a-field_a2 .a-field__input:focus~.a-field__label-wrap::after {
width: 100%;
}
/* a-field_a3 */
.a-field_a3 {
padding-top: 1.5em;
}
.a-field_a3 .a-field__label-wrap::after {
content: "";
box-sizing: border-box;
width: 100%;
height: 0;
opacity: 0;
border: var(--uiFieldBorderWidth) solid var(--fieldBorderColorActive);
position: absolute;
bottom: 0;
left: 0;
will-change: opacity, height;
transition: height .2s ease-out, opacity .2s ease-out;
}
.a-field_a3 .a-field__input:focus~.a-field__label-wrap::after {
height: 100%;
opacity: 1;
}
.a-field_a3 .a-field__input:focus~.a-field__label-wrap .a-field__label {
bottom: calc(var(--uiFieldHeight) + .5em);
}
/*
=====
LEVEL 4. SETTINGS
=====
*/
.field {
--fieldBorderColor: #D1C4E9;
--fieldBorderColorActive: #673AB7;
}
/*
=====
DEMO
=====
*/
body {
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Open Sans, Ubuntu, Fira Sans, Helvetica Neue, sans-serif;
margin: 0;
min-height: 100vh;
display: flex;
flex-direction: column;
}
.page {
box-sizing: border-box;
width: 100%;
max-width: 1000px;
margin: auto;
padding: 15px;
display: grid;
grid-gap: 30px;
align-items: flex-end;
order: 1;
}
@media (min-width: 481px) {
.page {
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.16/jquery.mask.min.js"></script>
<body>
<div class="page">
<label class=" field a-field a-field_a2">
<input id="balance" class="amount field__input a-field__input" placeholder="e.g. $500" required>
<span class="a-field__label-wrap">
<span class="a-field__label">Current Balance</span>
</span>
</label>
<label class="field a-field a-field_a2">
<input id="daily" class="amount field__input a-field__input" placeholder="e.g. 15" required>
<span class="a-field__label-wrap">
<span class="a-field__label">Daily Percentage Goal</span>
</span>
</label>
<label class="field a-field a-field_a2">
<input id="pips" class=" field__input a-field__input" placeholder="e.g. 50" required>
<span class="a-field__label-wrap">
<span class="a-field__label">Average Pips Per Day</span>
</span>
</label>
<label class="field a-field a-field_a2">
<input id="LotSize" class="field__input a-field__input" readonly required>
<span class="a-field__label-wrap">
<span class="a-field__label">Lot Size</span>
</span>
</label>
</div>
<div class="linkedin">
<div class="linkedin__container">
</div>
</div>
</body>