繁体   English   中英

在html中调用函数并将其设置为变量

[英]Calling function in html and setting it to a variable

我正在尝试从HTML页面调用函数getWidth(heading)并将其设置为可变width ,如下所示:

HTML页面:

div> style="white-space: nowrap; text-overflow: ellipsis; width:{{getWidth(heading)}}px; overflow: hidden; max-height:48px;" data-ng-bind="$eval('row.' + heading.key) | formatter:heading.format" title="{{$eval('row.' + heading.key) | formatter:heading.format}}">

功能:

$scope.getWidth = function(heading){
  return  document.getElementById($scope.tableId).scrollWidth*heading.width/100 - 24;
            };

我用花括号添加函数的方式。Chrome正在计算宽度,但在IE11中,该函数不起作用。 有人可以帮忙吗?

你的意思是这样吗?

的HTML:

<div onclick="function(params)">content...</div>

js:

function name(params) {
    var e = document.getElementById("idHere");
    e.width = params;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM