1

I have used jQuery to populate the value of a text input.

$(".textInput").val("foo");

When I look at the page, "foo" appears in the input, however, when I inspect the element in Chrome, "foo" is nowhere to be seen in the HTML.

Also, I have done something similar with a element using .text() and it worked fine (despite the fact that jQuery's docs say you can only use .val()).

djfdev
  • 5,747
  • 3
  • 19
  • 38
  • It is impossible to see an element that is not in the DOM.... It is also impossible to help you without any link to a test page... – Karl-André Gagnon May 20 '14 at 19:39
  • is this being added to the dom *after* the initial load? it won't be in the in the mark-up if it is on a document.ready call – Phlume May 20 '14 at 19:39
  • If the value is showing in the control, it is being populated correctly. .text should only be used to populate label elements. – ORION May 20 '14 at 19:39
  • What do you mean by "nowhere to be seen in the html"? JavaScript updates the DOM, not the html source. – David Thomas May 20 '14 at 19:39
  • If you type in a text input and look at the DOM you also won't see it in the element. – j08691 May 20 '14 at 19:40
  • you can see it in the textbox if you enable [shadow dom](http://www.html5rocks.com/en/tutorials/webcomponents/shadowdom/), but I don't think that's what you're going for. – ncksllvn May 20 '14 at 19:47
  • I found a relevant answer in this post [link](http://stackoverflow.com/questions/11873721/jquery-val-change-doesnt-change-input-value). For some reason the change is not reflecting in Chrome's inspector. – djfdev May 20 '14 at 20:09

1 Answers1

0

You will need to view the generated source. This is generated after the dom tree is executed.

You can view generated source by using tools such as Fidder or Web Developer Toolbar

Mike
  • 1,436
  • 9
  • 16