jquery 设定控件属性

来源:互联网 发布:淘宝运费险在哪设置 编辑:程序博客网 时间:2024/06/05 03:31

利用Jquery设定控件的属性时,比如 img标签:

 

如下设定它的图片显示,是没有问题的:

 $('#imgtest').attr("src", "themes/PNG/new2.gif");

 

如果想设定其不可见,要用到style里面的内容

我们可能会犯下面的错误

   $('#imgtest').attr("display", "none");

 

实际上应该是:

   $('#imgtest').attr("style", "display:none");