我在我的 javascript 函数中使用了以下行来显示带有类的元素。
<script type="text/javascript">
function showRates()
{
//load next page
alert("hi");
document.getElementsByClassName('myp').style.display = "block";
}
但是,显示 block 没有出现。
最佳答案
由于您使用的是 jquery-mobile ,为什么不用呢?
$('.myp').css('display', 'block');
此外,请记住 getElementsByClassName
返回一个 NodeList
并且没有 style
属性。如果您不想使用 jQuery,则必须遍历列表中的元素,然后应用 .style.display
更改。
关于css - 在 javascript jquery mobile 中显示隐藏和显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20866517/