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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:38:15+00:00 2026-05-11T23:38:15+00:00

I am not sure whether this only happens to me. Basically if I have

  • 0

I am not sure whether this only happens to me. Basically if I have a new element added to the page using YUI

var element = new YAHOO.util.Element(document.createElement('input'));
element.set('value', 'some value');
element.appendTo(document.body);

Then I read the value of the element using these different ways, and get consistent result

element.get('value'); // get 'some value'
element.get('element').getAttribute('value'); // get 'some value'
element.get('element').value; // get 'some value'
// jquery as reference
jQuery(element.get('element').val()); // get 'some value'

If I change the field value through the browser (for example, ‘new value’), and repeat the above steps again, i get some interesting values

element.get('value'); // get 'some value'
element.get('element').getAttribute('value'); // get 'some value'
element.get('element').value; // get 'new value'
// jquery as reference
jQuery(element.get('element').val()); // get 'new value'

However, if the input element is already exists in the page and is currently holding user input -> ‘some value’

var element2 = new YAHOO.util.Element('some_input');

First read get same result as above scenario

element.get('value'); // get 'some value'
element.get('element').getAttribute('value'); // get 'some value'
element.get('element').value; // get 'some value'
// jquery as reference
jQuery(element.get('element').val()); // get 'some value'

if the user enters ‘new value’ to the input field through the browser, then repeating the above steps gets

element.get('value'); // get 'new value'
element.get('element').getAttribute('value'); // get 'new value'
element.get('element').value; // get 'new value'
// jquery as reference
jQuery(element.get('element').val()); // get 'new value'

I am just wondering why would I get different values for dynamically generated element if different way of retrieving data is used, or it is just because I am doing it wrong?

  • 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-11T23:38:15+00:00Added an answer on May 11, 2026 at 11:38 pm

    Old values popping up might be a caching issue.

    I built your example using the latest YUI libraries here: http://tivac.com/yui2/jeffrey04_element.htm (you’ll want to have Firebug open).

    Using the correct

    element.get('value');
    

    calls is returning the proper value for me in both cases.


    Not sure why

    element.get('element').getAttribute('value')
    

    is returning null sometimes though.

    If you can narrow down the cases where it’s returning an incorrect value I would create a simple test case and submit a bug. They really appreciate feedback like that and are generally fast to respond and fix issues.

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

Sidebar

Related Questions

I am not sure whether distinct is the right word for this. I have
I'm not sure whether this question belongs on StackOverflow or SuperUser, but here goes
we're having this toshiba barcode printer. I'm not sure whether this problem is hardware
I'm not sure whether or not this is the appropriate way of doing this,
I am not sure whether I am asking this with the right words, I
I'm not sure whether these are programming questions, but I'm sure lots of new
Just a sidenote : I'm not sure whether I should post this to serverfault
Not sure whether this should be asked here or on another site such as
I am not sure whether this has been asked before; I did a few
Not sure whether its a duplicate or not-why my left and right border are

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.