David David - 2 months ago 8
CSS Question

How to Apply CSS to input tag values

I have a input tag with this css.

#myInput {
position: relative;
border: 1px solid #95B8E7;
background-color: #fff;
height: 30px;
vertical-align: middle;
display: inline-block;
overflow: hidden;
white-space: nowrap;
margin: 0;
padding: 0;
-moz-border-radius: 5px 5px 5px 5px;
-webkit-border-radius: 5px 5px 5px 5px;
border-radius: 5px 5px 5px 5px;

I wanted my Input field value should be
and ';' at the end. How should I write CSS for that.

Here is I am setting my input Value.

function selectItem(input, value) {
input.value += " "+value+";";


Answer Source

Add text-decoration: underline; to your CSS, and just call your function by selecting your HTML element, like so: selectItem(document.getElementById('myInput'),'foo').

Working Jsfiddle: https://jsfiddle.net/tacj0eeq/2/