Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7011053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:04:41+00:00 2026-05-27T22:04:41+00:00

For example, I have two p tags and in each of them are two

  • 0

For example, I have two p tags and in each of them are two inputs (these input just take numbers). I want to add the numbers in each tag p on input and when that’s done, alert the highest number in these two p tags.

Example:

First p: first input number(value) is: 1, second input
is: 2.
Second p: first input: 3, second input is: 4.

Adding the numbers in each tag p:
First p: 3 &
Second p: 7

I want to alert 7, because it is highest
number,

How do I do this by jQuery?

My try:(this doesn’t work)

<p>
    <input type="text" value="1"/>
    <input type="text" value="2"/>
</p>
<p>
    <input type="text" value="3"/>
    <input type="text" value="4"/>
</p>


$('button').live('click', function(){    
    var i = 0;
    $('p').each(function(){        
        $('input',this).each(function(){
            i += Number($(this).val());
            //alert(val);
            //if(val > i)  {i = val; }
        })
        var val = Math.max.apply( Math, $(i).map( function(){
            return 0|this.value;
        }).get());
        alert(val);
    });     
});

Demo: http://jsfiddle.net/uj4xr/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:04:41+00:00Added an answer on May 27, 2026 at 10:04 pm
    var max=0;
    $("p").each(function(){ 
        var i; 
        $("input",this).each(function(){
            i+= Number($(this).val());
        });
        if (i>max) max=i;
    })
    alert(max);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two example. First is true and second is wrong. It's just different
Let's take an example where we have two entities: ServiceProvider and TelephoneNumber . The
I want to have two select tags in html, one for hour and one
Suppose I have a tags table with two columns: tagid and contentid . Each
In the following example I have two years worth of data denoted by data_2007
I have two websites: http://example.com http://example.com/sub I have a page, let's say: http://example.com/sub/page1 Is
I have two html pages on my webserver www.example.com/desktop.html www.example.com/mobile.html In principle the content
I have two virtual hosts on windows(for example: test1.dev and test2.dev). But it always
We have two A records pointing to same public IP address as: www.example.com IN
I have two tables, for example: Table A Table B ======= ======= Name |

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.