1

Hello Everyone @ Stack Overflow, I've searched in-depth to no avail.

Background: I'm developing a web application using visual web developer express 2010, and using Bootstrap for css.

I have a text-input form control on my site for the user to enter a search query.

Problem: this text-input form control has no value or text attribute. Even when there is clearly a value/text that I am typing in.

Image of textbox and html code

I planned on my javascript changing the text in the textbox to the selection of a list-item.

If I can provide any other information or code, please let me know & I will update.

My theory is the Bootstrap JavaScript & Jquery libraries are interfering, but i haven't a clue where to start probing.

mayoBull
  • 71
  • 4

1 Answers1

4

value is an attribute on the DOM node's in-memory JavaScript representation, which has a getter that will retrieve the current value of the input and a setter that will update it on-screen, but not in the computed page. However, the HTML attribute value and the in-memory parameter are not kept in sync by default. That is, the computed HTML does not keep track of what the user has typed, but the value JavaScript attribute does. You can go ahead and update your input using something like:

$(input).val(someListValueOrWhatever)

Or, de-jQuery-ified:

input.value = someListValueOrWhatever

And the element will update on-screen just fine. Bootstrap and jQuery don't interfere.

Steven Petryk
  • 683
  • 4
  • 11
  • _"value is an attribute"_, I things you must refer it as a `property` instead! Refer [_this_](http://stackoverflow.com/questions/5874652/prop-vs-attr) – Rayon Apr 25 '16 at 04:07
  • 1
    "Property" and "attribute" are virtually interchangeable in most programmers' lexicons. I'm not really concerned with jQuery's specific choice of terminology, and most shouldn't be either. – Steven Petryk Apr 25 '16 at 04:11
  • _""Property" and "attribute" are virtually interchangeable"_ Not really... Refer the answer provided by great _T.J. Crowder_, _"A DOM element is an object, a thing in memory. Like most objects in OOP, it has properties. It also, separately, has a map of the attributes defined on the element (usually coming from the markup that the browser read to create the element). Some of the element's properties get their initial values from attributes with the same or similar names."_ And it is not specific to `jQuery`! – Rayon Apr 25 '16 at 04:19