Search code examples
javascripthtmlcssplaceholderpre

how to place formatted code in a placeholder in an html


I would like to have a formatted piece of code/json in my html placeholder.
I would like the placeholder to be formatted the way I have it in the html.

i.e.

   <textarea rows="9" data-bind="textInput: someVariable" 
     class="form-control" 
     placeholder=
        'e.g.
        {
            "type": "service_type",
            "project_id": "test-237012",        
            "client_email": "[email protected]",
            "client_id": "111390682349634407434",
            ....
        }'>   
    </textarea> 

How ?


Solution

  • You might need to add the cols attribute as well. See below.

    <textarea rows="10" cols="50" placeholder='e.g.
        {
            "type": "service_type",
            "project_id": "test-237012",        
            "client_email": "[email protected]",
            "client_id": "111390682349634407434",
            ....
        }'></textarea>