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;
 }

js获取焦点位置,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。