Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Tapio Mäntysalo
FS2 kertaus wk1
Commits
2e2a4c94
Commit
2e2a4c94
authored
Mar 28, 2020
by
Tapio Mäntysalo
Browse files
Now Bootstrap example works. Go to sleep.
parent
a1e2c03a
Changes
2
Hide whitespace changes
Inline
Side-by-side
index.html
View file @
2e2a4c94
...
...
@@ -23,7 +23,7 @@
<div
class=
"input-group-prepend"
>
<span
class=
"input-group-text"
id=
"basic-addon1"
>
Enter a positive integer
</span>
</div>
<input
type=
"text"
class=
"form-control input-example"
placeholder=
"
1
"
<input
type=
"text"
class=
"form-control input-example"
placeholder=
""
id=
"input-example-1"
aria-label=
"positive-integer-1"
aria-describedby=
"basic-addon1"
>
</div>
...
...
@@ -34,7 +34,7 @@
<span
class=
"input-group-text"
id=
"basic-addon2"
>
Enter another positive
integer
</span>
</div>
<input
type=
"
number
"
class=
"form-control input-example"
placeholder=
"
2
"
<input
type=
"
text
"
class=
"form-control input-example"
placeholder=
""
id=
"input-example-2"
aria-label=
"positive-integer-2"
aria-describedby=
"basic-addon2"
>
</div>
...
...
@@ -44,14 +44,7 @@
</tr>
</tbody>
</table>
<div>
<button
type=
"button"
class=
"btn btn-primary btn-example"
id=
"btn-example"
>
Calculate
</button>
</div>
<hr>
<p
id=
"card-example-result"
>
This is some text within a card body.
</p>
</div>
<p
id=
"card-example-result"
></p>
</div>
</div>
...
...
new_example.js
View file @
2e2a4c94
$
(
"
#card-example-result
"
).
text
(
""
);
$
(
'
.input-example
'
).
val
(
"
1
"
);
$
(
'
.input-example
'
).
val
(
"
0
"
);
$
(
"
.input-example
"
).
keyup
(
function
()
{
let
s
=
$
(
this
).
val
();
s
=
s
.
replace
(
/
\D
/g
,
''
);
$
(
this
).
val
(
s
);
});
$
(
"
#btn-example
"
).
click
(
function
()
{
let
a
=
$
(
"
#input-example-1
"
).
val
();
let
b
=
$
(
"
#input-example-2
"
).
val
();
$
(
this
).
val
(
+
s
);
//
});
//
$("#btn-example").click(function () {
let
a
=
+
$
(
"
#input-example-1
"
).
val
();
let
b
=
+
$
(
"
#input-example-2
"
).
val
();
let
gcd
=
getGreatestCommonDivisor
(
a
,
b
);
$
(
"
#card-example-result
"
).
text
(
`Greatest common divisor =
${
gcd
}
`
);
});
function
getGreatestCommonDivisor
(
a
,
b
)
{
// See https://www.geeksforgeeks.org/c-program-find-gcd-hcf-two-numbers/
if
(
b
==
0
)
return
a
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment