无法将Js变量绑定到表列标题标记中

时间:2018-03-07 12:29:45

标签: javascript jquery

var q = "SELECT Name, Address FROM Login where Login = 'app'"; 
var tablerow = "<tr> <td title="+q+"></td> </tr>" 

当我将光标移到表格列上时。它显示:

SELECT Name,Address FROM Login Login =

未显示完整字符串

1 个答案:

答案 0 :(得分:2)

对我来说这很好用:

img

所以我只是使用这些行:

&#13;
&#13;
window.onload = function() {
    hoverinfo.title = "SELECT Name, Address FROM Login where Login = 'app'";
}
&#13;
<table>
  <tr> 
    <td id="hoverinfo">hover</td>
  </tr> 
</table>
&#13;
&#13;
&#13;

  

使用动态代码(fiddle):

&#13;
&#13;
var q = "SELECT Name, Address FROM Login where Login = 'app'";
var tablerow = "<tr> <td title=\""+q+"\"> title </td> </tr>"

window.onload = function() {
  table.innerHTML += tablerow
}
&#13;
<table id="table">


</table>
&#13;
&#13;
&#13;