我有这个函数,它接受一个文本字符串,例如“Hello there,my nameis¬¬John¬¬¬”,并且函数试图在一个按钮中输出由'¬¬-'包围的文本。弹出窗口附带一个菜单选项列表,但是,当按钮显示正常,正确设置样式并在悬停时显示链接时,弹出的ul列表在单击时不会出现。整个函数低于上下文(显然大多数函数可能与问题无关)。我真的很感激一些帮助,因为我已经搜索了一段时间寻找答案:
function displayText( element, txt )
{
console.log("lesson text:" + txt);
var buildtext = '<span>';
if(txt.indexOf("¬¬¬") != -1)
{
var splitarr = txt.split("¬¬¬");
for (var i=0;i<splitarr.length;i++)
{
if( i%2 == 1 )
{
buildtext += '<a href="#fwordPopupMenu' + i + '" data-rel="fwordPopup" data-role="button" data-inline="true" data-transition="slideup" data-icon="false" data-theme="e">' + splitarr[i] + '</a>' +
'<div data-role="popup" id="fwordPopupMenu' + i + '" data-theme="d">' +
'<ul data-role="listview" data-inset="true" style="min-width:210px;" data-theme="d">' +
'<li><a href="#">View details</a></li>' +
'</ul>' +
'</div>';
}
else
{
buildtext += splitarr[i];
}
console.log(splitarr[i]);
}
buildtext += '</span>';
}
else // text contains no special words so display as is
{
buildtext = txt;
}
$(element).html(buildtext);
if( element == '#tutor-paragraph' )
{
//document.getElementById("tutor-paragraph").style.webkitAnimationName = "";
console.log("reseting animation");
$('#tutor-paragraph').addClass('run-animation');
//document.getElementById("tutor-paragraph").style.webkitAnimationName = "example";
}
//refresh element to get styling
$(element).trigger('create');
//$('element').selectmenu('refresh', true);
}