我正在尝试使用 qtip2.我的问题是我只想在用户点击内部指定html的href时显示工具提示.所以我试试这个: function help(){ var link = document.getElementById('helps'); if(link.innerHTML=="Open"){ $('#helps').q
function help(){ var link = document.getElementById('helps'); if(link.innerHTML=="Open"){ $('#helps').qtip({ content: { text: 'I get shown on click' }, show: { event: 'click' } }); link.innerHTML = "Close"; }else{ link.innerHTML="Open"; } } <a href="javascript:help()" id="helps">Open</a>
我的问题是,当我单击时,文本变为关闭但工具提示不显示.当我再次单击时,文本变为打开,我看到工具提示.我能做什么?
您应该在onclick处理程序之前初始化qtip.$('#helps').qtip({ content: { text: 'I get shown on click' }, show: { event: 'click' } }); function help() { var link = document.getElementById('helps'); if (link.innerHTML == "Open") { link.innerHTML = "Close"; } else { link.innerHTML = "Open"; } } < a href = "javascript:help()" id = "helps" > Open < /a>