user1104028
user1104028

Reputation: 397

How to set contents of a BootStrap Input Group using jQuery?

Below is an example of Bootstrap Code to create a input-group. How can I use jQuery to set the contents of the input-group using the id?

<div class = "container">
<div class = "input-group-addon">Your name</span>
<input type="text" class="form-control" id="inputField" placeholder="Full Name">
</div><br> 

Also, is there a way I can make the input-group not editable. I want to use it to display read-only text.

$("inputField").???? <-- What goes here??

Thanks!!

Upvotes: 0

Views: 953

Answers (2)

Rudi
Rudi

Reputation: 2995

$('#inputField').val('the value');

Upvotes: 1

bormat
bormat

Reputation: 1379

$("#inputField").attr('readonly',true).val('myValue')

if you have access to the html put directly readonly="readonly" as attribute of input. you can put value directly in HTML with the value attribute. ps: dont forget the "#"

Upvotes: 1

Related Questions