html 怎么获取焦点的位置,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 = "您填的百分比已经

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值