使用javascript中的title属性将鼠标悬停在数据上

时间:2013-04-24 21:38:55

标签: javascript jquery hover tooltip

我有一个javascript代码,以表格格式显示数据,当悬停在第一列时,它会显示其他详细信息。悬停在代码上的是使用jquery工具提示和html的title属性。代码在大多数情况下都能正常工作,但是如果我在悬停中显示的某个字段有“符号”,它会将所有记录的内容和悬停和主数据显示在一起,并且悬停在这些行上不起作用。

下面的

是我的代码的快照

var medicationName = medJSON.MED_DETAILS[medIdx1].ORDER_NAME;
     var orderdetails = medJSON.MED_DETAILS[medIdx1].ORD_DETAILS;
      var comments = medJSON.MED_DETAILS[medIdx1].ORD_COMMENTS;
      var reqStart = medJSON.MED_DETAILS[medIdx1].REQ_ST_DT;
      var originalStart = medJSON.MED_DETAILS[medIdx1].ORIG_ORD_DT;
      var lastDose = medJSON.MED_DETAILS[medIdx1].LAST_DOSE;
      var nextDose = medJSON.MED_DETAILS[medIdx1].NEXT_DOSE;
      var stopDt = medJSON.MED_DETAILS[medIdx1].STOP_DT_TM;
      var stopReason = medJSON.MED_DETAILS[medIdx1].STOP_REASON;
      var enteredBy = medJSON.MED_DETAILS[medIdx1].ORDER_ENTERED_BY;
      var status = medJSON.MED_DETAILS[medIdx1].ORD_STATUS;
      var simpleDetails = medJSON.MED_DETAILS[medIdx1].CLIN_DISP_LN;
      if(nextDose.length == 0)
      {
      nextDose = "Not Defined";
      }
      var medHover = ["<table><tr><td><b>Medication:</b></td><td>",medicationName,"</td></tr>"
                        ,"<tr><td><b>Details:</b></td><td>",simpleDetails,"</td></tr>"
                        //,"<tr><td><b>Order Comments:</b></td><td>",comments,"</td></tr>"
                          ,"<tr><td><b>Request Start:</b></td><td>",reqStart,"</td></tr>"
                          ,"<tr><td width = 200px><b>Original Order Date/Time:</b></td><td>",originalStart,"</td></tr>"
                          ,"<tr><td><b>Last Documented Dose:</b></td><td>",lastDose,"</td></tr>"
                          ,"<tr><td><b>Next Scheduled Dose:</b></td><td>",nextDose,"</td></tr>"
                          ,"<tr><td><b>Stop Date/Time:</b></td><td>",stopDt,"</td></tr>"
                          ,"<tr><td><b>Stop Reason:</b></td><td>",stopReason,"</td></tr>"
                          ,"<tr><td><b>Order Entered By:</b></td><td>",enteredBy,"</td></tr>"
                          ,"<tr><td><b>Status:</b></td><td>",status,"</td></tr>"
                          ,"</table>"]


     tempStr1.push("<tr class = 'evenrow' ><td class = 'cmedname custhvr' title=\"",medHover.join(""),"\">",medicationName,"</td><td> ",simpleDetails,"</td></tr>")  

感谢, SID

1 个答案:

答案 0 :(得分:0)

使用以下方法处理medHover:

medHover.join("").replace('\"', '&quot;');

这会将引号字符替换为可用于HTML的值。