user4065758
user4065758

Reputation: 319

Use input element as content in tooltip

Let's assume I have a bootstrap tooltip appended on a div element

<div class="text-center text" data-container="body" 
     data-toggle="popover" data-placement="left" 
     data-content="Some content">Text</div>

How can I create an input element to use as a content, instead of just text.

I've tried

data-content="<input type='text'>

But it returnts it as a string. Also creating an input object and trying to append it with javascript doesn't work:

var input = document.createElement("input");
input.type="text";
myTooltip.setAttribute("data-content", input);

Any ideas?

Upvotes: 0

Views: 243

Answers (1)

teran
teran

Reputation: 3234

you should set data-html attribute to true to use html content or title for popover.

see jsfidle example

ps: it has no sense for hover trigger.

<a href="#" class="btn btn-primary" style="margin: 250px;"
       data-placement="left"
       data-trigger="click"
       data-html="true">test</a>



$(".btn").popover({ content : '<b>test</b><input type="text">' });

Upvotes: 1

Related Questions