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

  • Home
  • SEARCH
  • 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 6754121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:14:33+00:00 2026-05-26T13:14:33+00:00

<input id=aaa1 value=vvv> <input id=aaa2 value=> <input id=aaa3 value=ooo> <input id=aaa4 value=> <input id=aaa5

  • 0
<input id="aaa1" value="vvv">
<input id="aaa2" value="">
<input id="aaa3" value="ooo">
<input id="aaa4" value="">
<input id="aaa5" value="ooo">
<input id="aaa6" value="ooo">

if($('input[id^="aaa"]').val().length == 0){
    $('input[id^="aaa"]').css('background-color', 'red');
}

$("#aaa1").live("click", function(){
  $(this).after("<input id='aaax' value='ooo'>");
});

why this working only for first input? if first input value is null then this add css for all input.
how can i make it separately for all input? i use also function live() – i would like added this also for new input

LIVE EXAMPLE: http://jsfiddle.net/Zm5jp/1/

  • 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-26T13:14:34+00:00Added an answer on May 26, 2026 at 1:14 pm

    You need to iterate over the inputs matched using each;

    $('input[id^="aaa"]').each(function () {
        var self = $(this);
    
        if (self.val().length == 0) {
            self.css('background-color', 'red');
        }
    }
    

    As stated in the docs for val();

    Get the current value of the first element in the set of matched elements.

    I.e. your code translates as “if the first input value is empty, set the background CSS for all elements”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Input rz value In the head I have: Event.observe(window, 'load', function() { $$(input).each(function(field){ Event.observe(field,
input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;} input,textarea,select{*font-size:100%;} This is from the YUI reset css. What does the * before
input type=text/radio/checkbox - can I treat them differently in my CSS? Other than by
input type=button name=colr value= Blue onclick=document.bgColor='#0000FF' Basically i have done buttons using javascipt to
Input: var text = $('#id_textarea').val(); var keywords = $('#id_keywords').val().split(','); Output: Number of keywords in
INPUT <logs> <logentry revision=648> <author>nshmyrev</author> <date>2008-09-21T19:43:10.819236Z</date> <paths> <path action=M>/trunk/po/ru.pi</path> </paths> <msg>2008-09-21 Nickolay V. Shmyrev
Input: 1) A huge sorted array of string SA; 2) A prefix string P;
Input @StartDate = '01/25/2010' @EndDate = '02/06/2010' I have 2 CTEs in a stored
Input : {5, 13, 6, 5, 13, 7, 8, 6, 5} Output : {5,
Input: SHC 111U,SHB 22x,, SHA 5555G Needed output: SHB 22X, SHC 111U, SHA 5555G

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.