Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put div inside input type text

Tags:

html

jquery

How can i put a div inside text field of a html form

<h2>Skills</h2>
<label for="skills">Choose your skills</label>
<input id="skills" type="text"/>

Please note my english is not good. So i can't tell you more.

I just want to render each skill in each div.

my jquery code(separated by comma) is :

$("input#skills").keydown(function(e){
   if(e.which===188){
      var skbl = $.trim($("input#skills").val());
      $("input#skills").append("<div style='background:green;'>"+skbl+"</div>");
});
like image 719
Rajesh Kumar Avatar asked Oct 07 '13 23:10

Rajesh Kumar


People also ask

What is div tag in HTML?

The <div> tag defines a division or a section in an HTML document. The <div> tag is used as a container for HTML elements - which is then styled with CSS or manipulated with JavaScript. The <div> tag is easily styled by using the class or id attribute.

How do I put text into a div?

You can call $("#myText"). val() to get the text of the text box, and $("#txtDiv"). text(txtToAppend) to append it to the div.

Can you put a div inside an input?

You can't place any element inside an input. An input does not contain any HTML. Save this answer.


1 Answers

You can't place any element inside an input. An input does not contain any HTML.

like image 110
Colandus Avatar answered Oct 02 '22 00:10

Colandus