removeAttr(“style”)不工作 [英] removeAttr("style") doesn't work
问题描述
我有这个网站: http://thc-cup.ucoz.com/
并使登录表单出现(通过按登录按钮)我必须删除div的默认隐藏的风格,我没有控制。
我使用这个代码:
< script> $(#baseLogForm)。removeAttr(style );< / script>
但是它不工作,div应该从哪里删除样式仍然存在。 p>
为什么它不工作?
感谢
您的代码不工作,因为当它运行时,您的DOM尚未准备好。
尝试此方式:
$(document).ready function(){
$(#baseLogForm)removeAttr(style);
});
或更短的方式...
$(function(){// <这是一个快捷方式到$(document).ready()
$(#baseLogForm)。removeAttr (style);
});
但是...
你可以简单地做一个 .show()
在此表单上,将删除表单样式属性中的 display:none
属性。 / p>
I have this website: http://thc-cup.ucoz.com/ And to make the login form appear (by pressing the login button) I have to remove the style of the div which is hidden by default and of which I have no control. I used this code:
<script>$("#baseLogForm").removeAttr("style");</script>
But it is not working, the div from where it should remove the style is still there.
Why it isn't working? Thanks
Your code isn't working because when it runs, your DOM isn't ready.
Try this way:
$(document).ready(function(){
$("#baseLogForm").removeAttr("style");
});
or the shorter way...
$(function(){ //<< This is a "shortcut" to $(document).ready()
$("#baseLogForm").removeAttr("style");
});
BUT...
You could simply do a .show()
on this form, this will remove the display: none
property in the style attribute of your form.
这篇关于removeAttr(“style”)不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!