如何在javascript

时间:2017-03-02 13:00:28

标签: javascript jquery asp.net

我在ASPX页面中有这段代码:

<iframe height="78%" width="100%" id="ifrmReport" scrolling="auto" name="ifrmReport" frameborder="0"></iframe>

我想根据特定条件在javascript或jQuery中更改此属性:scrolling="none""auto"。任何人都可以帮忙。感谢

2 个答案:

答案 0 :(得分:0)

您可以使用attr()prop()方法来实现此目的:

$('#ifrmReport').prop('scrolling', 'none');
// or
$('#ifrmReport').attr('scrolling', 'none');

答案 1 :(得分:0)

这很容易。

<强>的jQuery

if (condition===true) {
   jQuery("iframe#id").attr("scrolling", "none");
}

<强>的JavaScript

if (condition===true) {
   document.querySelector("iframe#id").setAttribute("scrolling", "none");
}