I make my own language using codemirror, what I want to do when I stop on name of function and hover on it or press on (Ctrl+I) to show tooltip display the type and other data for this function, the code run on jsfiddle.net but not run on jsbin.com
var cm = CodeMirror(document.getElementById("editor"), {
value: "function myScript() {\n return 100;\n}",
indentUnit: 4,
lineNumbers: true
});
var textMarker;
$('#add').click(function() {
textMarker = cm.markText({
line: 1,
ch: 4
}, {
line: 1,
ch: 10
}, {
className: 'marked-text'
});
$('.marked-text').tooltip({
title: 'This is a return statement',
container: 'body',
delay: { "show": 500, "hide": 100 },
animation: false
});
});
$('#remove').click(function() {
if (textMarker) {
textMarker.clear();
}
});
工作代码的链接:这里的代码有效 https://jsfiddle.net/NathanFriend/tooaq4oc/
我的尝试但不起作用:my try http://jsbin.com/jemapovira/edit?html,js,output