Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make an HTML input field appear as just the text in the field

I have an HTML form with a number of input fields that are added dynamically with content in each field using jQuery.

Is it possible to hide the fact that these fields are input fields and only display them as the content in the field?

I don't want to hide the entire field and it's contents --- just hide the fact that its an input type field.

I've tried jQuery's hide() and $('#foo').css('display','none'), but that hides the entire field.

The idea is that there could be a large number of fields, but I don't want the user to see all the input text fields.

like image 448
Raj Avatar asked Aug 29 '13 22:08

Raj


2 Answers

Start with something like this:

input {
    border: none;
    outline: none;
    background-color: transparent;
    font-family: inherit;
    font-size: inherit;
}
like image 175
Trevor Dixon Avatar answered Sep 27 '22 21:09

Trevor Dixon


How about something like this :

$('.dynamic input').each(function() {
    $('<div/>').html($(this).val()).insertAfter($(this).hide());
});
like image 42
OneOfOne Avatar answered Sep 27 '22 21:09

OneOfOne