removeAttr(“style”)不工作 [英] removeAttr("style") doesn't work

查看:437
本文介绍了removeAttr(“style”)不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个网站: 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆