input the number and find the largest and lowest number using jqueryIs there an “exists” function for jQuery?Add table row in jQueryHow do I check if an element is hidden in jQuery?Setting “checked” for a checkbox with jQuery?How can I know which radio button is selected via jQuery?How to check whether a checkbox is checked in jQuery?Disable/enable an input with jQuery?How can I refresh a page with jQuery?jQuery scroll to element“Thinking in AngularJS” if I have a jQuery background?
How to justify getting additional team member when the current team is doing well?
Why did UK NHS pay for homeopathic treatments?
Medic abilities
How to deal with a Homophobic PC
Clear text passwords in Unix
What secular civic space would pioneers build for small frontier towns?
Are fuzzy sets appreciated by OR community?
A famous scholar sent me an unpublished draft of hers. Then she died. I think her work should be published. What should I do?
What does מעלה עליו הכתוב mean?
Is a Middle Name a Given Name?
Beyond Futuristic Technology for an Alien Warship?
With an option to reduce any pair satisfying a relation, repeatedly reduce a collection.
Youtube not blocked by iptables
Hangman Game (YAHG)
What is the difference between an astronaut in the ISS and a freediver in perfect neutral buoyancy?
What does Sartre mean by "pédéraste" - pederast or homosexual?
My Project Manager does not accept carry-over in Scrum, Is that normal?
How 象【しょう】 ( ≈かたち、 すがた、ようす) and 象【ぞう】 (どうぶつ) got to be written with the same kanji?
Why, even after his imprisonment, people keep calling Hannibal Lecter "Doctor"?
Plotting curves within a foreach loop and attributing colors from a colormap
Algorithm that generates orthogonal vectors: C++ implementation
Need Improvement on Script Which Continuosly Tests Website
Is differentiation as a map discontinuous?
Why does C++ have 'Undefined Behaviour' and other languages like C# or Java don't?
input the number and find the largest and lowest number using jquery
Is there an “exists” function for jQuery?Add table row in jQueryHow do I check if an element is hidden in jQuery?Setting “checked” for a checkbox with jQuery?How can I know which radio button is selected via jQuery?How to check whether a checkbox is checked in jQuery?Disable/enable an input with jQuery?How can I refresh a page with jQuery?jQuery scroll to element“Thinking in AngularJS” if I have a jQuery background?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
<script type="text/javascript">
function largest() {
var num1, num2;
num1 = Number(document.getElementById("N").value);
num2 = Number(document.getElementById("M").value);
if (num1 > num2)
window.alert(num1 + "-is largest");
else if (num2 > num1)
window.alert(num2 + "-is largest");
</script>
javascript jquery arrays typescript if-statement
add a comment
|
<script type="text/javascript">
function largest() {
var num1, num2;
num1 = Number(document.getElementById("N").value);
num2 = Number(document.getElementById("M").value);
if (num1 > num2)
window.alert(num1 + "-is largest");
else if (num2 > num1)
window.alert(num2 + "-is largest");
</script>
javascript jquery arrays typescript if-statement
5
What is your question?
– benvc
Mar 28 at 18:26
add a comment
|
<script type="text/javascript">
function largest() {
var num1, num2;
num1 = Number(document.getElementById("N").value);
num2 = Number(document.getElementById("M").value);
if (num1 > num2)
window.alert(num1 + "-is largest");
else if (num2 > num1)
window.alert(num2 + "-is largest");
</script>
javascript jquery arrays typescript if-statement
<script type="text/javascript">
function largest() {
var num1, num2;
num1 = Number(document.getElementById("N").value);
num2 = Number(document.getElementById("M").value);
if (num1 > num2)
window.alert(num1 + "-is largest");
else if (num2 > num1)
window.alert(num2 + "-is largest");
</script>
javascript jquery arrays typescript if-statement
javascript jquery arrays typescript if-statement
edited Mar 28 at 18:25
Pranav C Balan
94.7k16 gold badges101 silver badges126 bronze badges
94.7k16 gold badges101 silver badges126 bronze badges
asked Mar 28 at 18:24
Benglenn DagalaBenglenn Dagala
22 bronze badges
22 bronze badges
5
What is your question?
– benvc
Mar 28 at 18:26
add a comment
|
5
What is your question?
– benvc
Mar 28 at 18:26
5
5
What is your question?
– benvc
Mar 28 at 18:26
What is your question?
– benvc
Mar 28 at 18:26
add a comment
|
1 Answer
1
active
oldest
votes
If I understand correctly, you're wanting to complete the code above so that the largest()
function can be called to identify the largest number between inputs with id="N"
and id="M"
.
One approach might be to introduce a <button>
element, and use jQuery to bind a click()
handler to it which would call largest()
like so:
function largest()
var num1, num2;
/* Update to use jQuery style selectors */
num1 = Number($("#N").val());
num2 = Number($("#M").val());
if (num1 > num2)
window.alert(num1 + " from N is largest and " + num2 + " from M is lowest");
else if (num2 > num1)
window.alert(num2 + " from M is largest and " + num1 + " from N is lowest");
/* Get the find-largest button, and add a click event listener which calls the
largest() function */
$("#find-largest").click(function()
/* Call the largest() function */
largest();
/* Prevent the buttons default behavior */
return false;
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js">
</script>
<div>
<label>Number N:</label>
<input id="N" type="number" />
</div>
<div>
<label>Number M:</label>
<input id="M" type="number" />
</div>
<!-- Add a button which when clicked calls largest() function -->
<div>
<button id="find-largest">Find largest</button>
</div>
but i need also find the lowest , sory if my code if not perfect i need to input a 2 number and show the largest and lowest
– Benglenn Dagala
Mar 29 at 4:32
@BenglennDagala not a problem - so you want to show an alert that displays which is the lowest, and which is the highest value?
– Dacre Denny
Mar 29 at 4:35
yes sir ive hardly thinking only the largest will show
– Benglenn Dagala
Mar 29 at 4:45
I updated the answer, does that help?
– Dacre Denny
Mar 29 at 4:53
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55404507%2finput-the-number-and-find-the-largest-and-lowest-number-using-jquery%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If I understand correctly, you're wanting to complete the code above so that the largest()
function can be called to identify the largest number between inputs with id="N"
and id="M"
.
One approach might be to introduce a <button>
element, and use jQuery to bind a click()
handler to it which would call largest()
like so:
function largest()
var num1, num2;
/* Update to use jQuery style selectors */
num1 = Number($("#N").val());
num2 = Number($("#M").val());
if (num1 > num2)
window.alert(num1 + " from N is largest and " + num2 + " from M is lowest");
else if (num2 > num1)
window.alert(num2 + " from M is largest and " + num1 + " from N is lowest");
/* Get the find-largest button, and add a click event listener which calls the
largest() function */
$("#find-largest").click(function()
/* Call the largest() function */
largest();
/* Prevent the buttons default behavior */
return false;
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js">
</script>
<div>
<label>Number N:</label>
<input id="N" type="number" />
</div>
<div>
<label>Number M:</label>
<input id="M" type="number" />
</div>
<!-- Add a button which when clicked calls largest() function -->
<div>
<button id="find-largest">Find largest</button>
</div>
but i need also find the lowest , sory if my code if not perfect i need to input a 2 number and show the largest and lowest
– Benglenn Dagala
Mar 29 at 4:32
@BenglennDagala not a problem - so you want to show an alert that displays which is the lowest, and which is the highest value?
– Dacre Denny
Mar 29 at 4:35
yes sir ive hardly thinking only the largest will show
– Benglenn Dagala
Mar 29 at 4:45
I updated the answer, does that help?
– Dacre Denny
Mar 29 at 4:53
add a comment
|
If I understand correctly, you're wanting to complete the code above so that the largest()
function can be called to identify the largest number between inputs with id="N"
and id="M"
.
One approach might be to introduce a <button>
element, and use jQuery to bind a click()
handler to it which would call largest()
like so:
function largest()
var num1, num2;
/* Update to use jQuery style selectors */
num1 = Number($("#N").val());
num2 = Number($("#M").val());
if (num1 > num2)
window.alert(num1 + " from N is largest and " + num2 + " from M is lowest");
else if (num2 > num1)
window.alert(num2 + " from M is largest and " + num1 + " from N is lowest");
/* Get the find-largest button, and add a click event listener which calls the
largest() function */
$("#find-largest").click(function()
/* Call the largest() function */
largest();
/* Prevent the buttons default behavior */
return false;
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js">
</script>
<div>
<label>Number N:</label>
<input id="N" type="number" />
</div>
<div>
<label>Number M:</label>
<input id="M" type="number" />
</div>
<!-- Add a button which when clicked calls largest() function -->
<div>
<button id="find-largest">Find largest</button>
</div>
but i need also find the lowest , sory if my code if not perfect i need to input a 2 number and show the largest and lowest
– Benglenn Dagala
Mar 29 at 4:32
@BenglennDagala not a problem - so you want to show an alert that displays which is the lowest, and which is the highest value?
– Dacre Denny
Mar 29 at 4:35
yes sir ive hardly thinking only the largest will show
– Benglenn Dagala
Mar 29 at 4:45
I updated the answer, does that help?
– Dacre Denny
Mar 29 at 4:53
add a comment
|
If I understand correctly, you're wanting to complete the code above so that the largest()
function can be called to identify the largest number between inputs with id="N"
and id="M"
.
One approach might be to introduce a <button>
element, and use jQuery to bind a click()
handler to it which would call largest()
like so:
function largest()
var num1, num2;
/* Update to use jQuery style selectors */
num1 = Number($("#N").val());
num2 = Number($("#M").val());
if (num1 > num2)
window.alert(num1 + " from N is largest and " + num2 + " from M is lowest");
else if (num2 > num1)
window.alert(num2 + " from M is largest and " + num1 + " from N is lowest");
/* Get the find-largest button, and add a click event listener which calls the
largest() function */
$("#find-largest").click(function()
/* Call the largest() function */
largest();
/* Prevent the buttons default behavior */
return false;
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js">
</script>
<div>
<label>Number N:</label>
<input id="N" type="number" />
</div>
<div>
<label>Number M:</label>
<input id="M" type="number" />
</div>
<!-- Add a button which when clicked calls largest() function -->
<div>
<button id="find-largest">Find largest</button>
</div>
If I understand correctly, you're wanting to complete the code above so that the largest()
function can be called to identify the largest number between inputs with id="N"
and id="M"
.
One approach might be to introduce a <button>
element, and use jQuery to bind a click()
handler to it which would call largest()
like so:
function largest()
var num1, num2;
/* Update to use jQuery style selectors */
num1 = Number($("#N").val());
num2 = Number($("#M").val());
if (num1 > num2)
window.alert(num1 + " from N is largest and " + num2 + " from M is lowest");
else if (num2 > num1)
window.alert(num2 + " from M is largest and " + num1 + " from N is lowest");
/* Get the find-largest button, and add a click event listener which calls the
largest() function */
$("#find-largest").click(function()
/* Call the largest() function */
largest();
/* Prevent the buttons default behavior */
return false;
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js">
</script>
<div>
<label>Number N:</label>
<input id="N" type="number" />
</div>
<div>
<label>Number M:</label>
<input id="M" type="number" />
</div>
<!-- Add a button which when clicked calls largest() function -->
<div>
<button id="find-largest">Find largest</button>
</div>
function largest()
var num1, num2;
/* Update to use jQuery style selectors */
num1 = Number($("#N").val());
num2 = Number($("#M").val());
if (num1 > num2)
window.alert(num1 + " from N is largest and " + num2 + " from M is lowest");
else if (num2 > num1)
window.alert(num2 + " from M is largest and " + num1 + " from N is lowest");
/* Get the find-largest button, and add a click event listener which calls the
largest() function */
$("#find-largest").click(function()
/* Call the largest() function */
largest();
/* Prevent the buttons default behavior */
return false;
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js">
</script>
<div>
<label>Number N:</label>
<input id="N" type="number" />
</div>
<div>
<label>Number M:</label>
<input id="M" type="number" />
</div>
<!-- Add a button which when clicked calls largest() function -->
<div>
<button id="find-largest">Find largest</button>
</div>
function largest()
var num1, num2;
/* Update to use jQuery style selectors */
num1 = Number($("#N").val());
num2 = Number($("#M").val());
if (num1 > num2)
window.alert(num1 + " from N is largest and " + num2 + " from M is lowest");
else if (num2 > num1)
window.alert(num2 + " from M is largest and " + num1 + " from N is lowest");
/* Get the find-largest button, and add a click event listener which calls the
largest() function */
$("#find-largest").click(function()
/* Call the largest() function */
largest();
/* Prevent the buttons default behavior */
return false;
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js">
</script>
<div>
<label>Number N:</label>
<input id="N" type="number" />
</div>
<div>
<label>Number M:</label>
<input id="M" type="number" />
</div>
<!-- Add a button which when clicked calls largest() function -->
<div>
<button id="find-largest">Find largest</button>
</div>
edited Mar 29 at 4:37
answered Mar 28 at 19:14
Dacre DennyDacre Denny
20.2k4 gold badges15 silver badges35 bronze badges
20.2k4 gold badges15 silver badges35 bronze badges
but i need also find the lowest , sory if my code if not perfect i need to input a 2 number and show the largest and lowest
– Benglenn Dagala
Mar 29 at 4:32
@BenglennDagala not a problem - so you want to show an alert that displays which is the lowest, and which is the highest value?
– Dacre Denny
Mar 29 at 4:35
yes sir ive hardly thinking only the largest will show
– Benglenn Dagala
Mar 29 at 4:45
I updated the answer, does that help?
– Dacre Denny
Mar 29 at 4:53
add a comment
|
but i need also find the lowest , sory if my code if not perfect i need to input a 2 number and show the largest and lowest
– Benglenn Dagala
Mar 29 at 4:32
@BenglennDagala not a problem - so you want to show an alert that displays which is the lowest, and which is the highest value?
– Dacre Denny
Mar 29 at 4:35
yes sir ive hardly thinking only the largest will show
– Benglenn Dagala
Mar 29 at 4:45
I updated the answer, does that help?
– Dacre Denny
Mar 29 at 4:53
but i need also find the lowest , sory if my code if not perfect i need to input a 2 number and show the largest and lowest
– Benglenn Dagala
Mar 29 at 4:32
but i need also find the lowest , sory if my code if not perfect i need to input a 2 number and show the largest and lowest
– Benglenn Dagala
Mar 29 at 4:32
@BenglennDagala not a problem - so you want to show an alert that displays which is the lowest, and which is the highest value?
– Dacre Denny
Mar 29 at 4:35
@BenglennDagala not a problem - so you want to show an alert that displays which is the lowest, and which is the highest value?
– Dacre Denny
Mar 29 at 4:35
yes sir ive hardly thinking only the largest will show
– Benglenn Dagala
Mar 29 at 4:45
yes sir ive hardly thinking only the largest will show
– Benglenn Dagala
Mar 29 at 4:45
I updated the answer, does that help?
– Dacre Denny
Mar 29 at 4:53
I updated the answer, does that help?
– Dacre Denny
Mar 29 at 4:53
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55404507%2finput-the-number-and-find-the-largest-and-lowest-number-using-jquery%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
5
What is your question?
– benvc
Mar 28 at 18:26