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 7439983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:47:02+00:00 2026-05-29T10:47:02+00:00

I have the following mark-up: $(document).ready(function () { $(‘.lalala’).bind(‘blur’, function (e) { CheckFirstInput($(this)); });

  • 0

I have the following mark-up:

$(document).ready(function () {
    $('.lalala').bind('blur', function (e) {
        CheckFirstInput($(this));
    });
});

<div id="divContainer">
    <input type="text" class="lalala" />
    <p id="img1"></p>
</div>

And the following script

function CheckFirstInput(element) {
    var txtLength = element.val();
    var parent;
    var lastElement;

    if (txtLength.length < 1) {
        parent = element.parent();
        lastElement = parent.last();
        lastElement.text('prazno e');
    }
    else {
        //element.parent().lastChild().text('4884384f384r34rf');
        parent = element.parent();
        lastElement = parent.last();                
        lastElement.text('ne e prazno');
    }
}

If the input field is not empty I want to select the last element of the wrapping div (<p>) and change its text. How do I do that?

Thanks in advance!!

  • 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-29T10:47:03+00:00Added an answer on May 29, 2026 at 10:47 am

    You needed to select the children() of the element’s parent. You were selecting the last parent. (Which is the parent.)

    The following is working. I also cleaned up the code a bit.

    $('.lalala').blur( function () {
          CheckFirstInput($(this));
    });
    
    function CheckFirstInput(element) {
            if (element.val().length < 1) {
                element.siblings(':last').html('prazno e');
            }
            else {
                element.siblings(':last').html('ne e prazno ');
            }
    }
    

    Working Fiddle

    http://jsfiddle.net/CRccw/2/

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

Sidebar

Related Questions

I have the following mark up <ul> <li>this is bullet list</li> <li>this is another
Problem I have the following mark-up: <div id=progress-bar> <div id=step-1 class=active><p>1. Select Room</p></div> <div
I have the following mark-up: <dt> <input id=p_method_checkmo value=checkmo type=radio name=payment[method] title=Check / Money
I have the following mark up. <ul> <li><a><span>link-1</span></a></li> <li><a><span>link-2</span></a></li> <li><a><span>link-3</span></a></li> </ul> When user hover
I have the following HTML mark up. <ul class=thumbs> <li> <strong>Should be level 0</strong>
I have following type of data and I want to produce bar graph. Mark
I have the following models: class Mark < ActiveRecord::Base validates_presence_of :user validates_presence_of :page belongs_to
I'm using following script to mark current page with a.active on the URL. $(function
I have the following mark-up: <table> <thead> ... </thead> <tbody> <tr> <td> <span class='select_me'
After feedback, complete rewrite of the question. I have the following mark up :

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.