简体   繁体   中英

How to add bold text in Tooltips in Javascript?

I'm using a native javascript method in my gwt project und try to add tooltips in the RTA http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/client/ui/RichTextArea.html . That works fine by using:

private native void addHtmlSpanHighlight(Element elem, String type, 
String objectId, String tooltip)/*-{ 
var range = elem.contentWindow.getSelection().getRangeAt(0), content = range 
.extractContents(), span = document.createElement('SPAN'); 

span.setAttribute("type", type); 
span.setAttribute("value", objectId); 
span.setAttribute("style", "background-color:#ffd700"); 
span.setAttribute("title", tooltip) 
span.appendChild(content); 

var htmlContent = span.innerHTML; 
range.insertNode(span); 
elem.blur(); 
}-*/; 

So the span has the tooltip. But here is my question:

Is there any smart and easy possibility to set bold tags in the String of the tooltip (example : title="This is a ) without using css or javascript frameworks? ”),这是一种既聪明又容易的可能性?

Many thanks in advance for your help.

You cannot style tooltips.

You can create a different element that will act as a tooltip, and style it. One possible technique is described here:

http://sixrevisions.com/css/css-only-tooltips/

尝试使用DecoratedPopupPanel,然后为面板添加鼠标悬停处理程序,请参见此链接中的示例

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM