我想實現一個插件:添加動態值的函數
$(".myTbl th:nth-child(1)").truncate({
width: "200",
after: "…",
center: false,
addtitle: true
});
而不是使用寬度固定的值,我有一個動態計算它並將其設置到AA變量的腳本,但是當我將它插入代碼中斷。我錯過了什麼?這是所有的PHP代碼
echo '
var myWidth = 150;
$(".myTbl th:nth-child(1)").truncate({
width: myWidth ,
after: "…",
center: false,
addtitle: true
}); ';
您是否嘗試過調試嗎?你有錯誤嗎? – talnicolas
您發佈的代碼沒有問題,所以問題在其他地方。 – simshaun
也許這個插件需要一個字符串,而在第二個代碼片段中你會提供一個數字。 –