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 = "您填的百分比已经
color=‘red‘>超出" + (count - 100) +
"%
";} else {
info =
"您最多还可以填写" + (100 - count) +
"%";
}
return
info;
}
function showHint(el)
{
/*var position =
getPosition(el);
var div = "
class=‘shadow1‘>
class=‘container‘>"
+ getHintInfo(el)
+
"
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‘];*/
//
// var info =
getHintInfo(el);
$(‘#‘ +
el.id).popover({
toggle:‘popover‘,
title:‘
size=2>可填百分比
‘,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;
}
原文:http://www.cnblogs.com/chchao/p/3654017.html