I have a form with some inputs and CSS attached to them that uses an attribute value selector to change the background color of the input depending on the value.
Example
<!DOCTYPE html>
<html>
<head><style>
input[value="foo"] { background-color: red; }
</style></head>
<body>
<form>
<input value="foo" />
<button/>
</form>
</body>
</html>
If I use fooas the value at boot, as in the code, the field will be red at boot, but if I change it, it will remain red. The same thing, if I change the input value to foo, it will not change the background color.
Similarly, if I use .val()in jQuery. Apparently, in these cases the "dynamic" value changes, while CSS refers to the "static" value.
$('button').on('click', function(ev) {
ev.preventDefault();
$('input[value="foo"]').val('bar');
// $('input[value="bar"]').val('baz'); // nothing is found
});
, foo bar, bar baz, .
attr, , jQuery ( SO), val - .
val() ?