js获取焦点位置
function showPrompt(el) {
var info = getHintInfo(el);
$("#" + el.id).attr("title", info);
}
function getHintInfo(el) {
var count = 0;
var info = "";
$("[name*=spendTimePercent]").each(
function () {
var val = parseFloat($(this).val());
if (!isNaN(val)) {
count += val;
}
}
);
if (count > 100) {
info = "您填的百分比已经<font color='red'>超出<b>" + (count - 100) + "%</b></font>";
} else {
info = "您最多还可以填写<b>" + (100 - count) + "%</b>";
}
return info;
}
function showHint(el) {
/*var position = getPosition(el);
var div = "<div class='shadow1'><div class='shadow2'><div class='shadow3'><div class='container'>"
+ getHintInfo(el) + "</div></div></div></div>";
document.getElementById('hintDiv').style.display = 'block';
document.getElementById("hintDiv").innerHTML = div;
document.getElementById('hintDiv').style.top = position['y'] + el.offsetHeight + 5 + "px";
document.getElementById('hintDiv').style.left = position['x'];*/
// <!-- onmousemove="showPrompt(this)" onblur="hideHint()" onkeyup="updateSpendTimePercent('${mapstatus.index}','${status.index }');"-->
// var info = getHintInfo(el);
$('#' + el.id).popover({
toggle:'popover',
title:'<font size=2><b>可填百分比</b></font>',
content:getHintInfo(el),
trigger:'manual',
html:true
});
$('#' + el.id).popover('show');
}
function hideHint(el) {
//document.getElementById('hintDiv').style.display = 'none';
$('#' + el.id).popover('destroy');
}
function getPosition(obj) {
var position = new Array();
position['x'] = obj.offsetLeft;
position['y'] = obj.offsetTop;
while(obj = obj.offsetParent)
{
position['x'] += obj.offsetLeft;
position['y'] += obj.offsetTop;
}
return position;
}
浙公网安备 33010602011771号