最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Disable img Tag - Stack Overflow

programmeradmin2浏览0评论

I need to disable img tag using javascript. what is the javascript code?

Example :

<img id='hrefId' src="/proteus/images/button_find.gif" alt="" />

Please help me

I need to disable img tag using javascript. what is the javascript code?

Example :

<img id='hrefId' src="/proteus/images/button_find.gif" alt="" />

Please help me

Share Improve this question edited Nov 25, 2011 at 9:51 Curtis 103k69 gold badges277 silver badges359 bronze badges asked Nov 25, 2011 at 9:49 SugaSuga 571 gold badge1 silver badge10 bronze badges 2
  • 6 Please explain what you mean by disable img tag? – Curtis Commented Nov 25, 2011 at 9:50
  • @Curt disabled means grey out – Ashish Kamble Commented Jul 8, 2021 at 10:19
Add a ment  | 

3 Answers 3

Reset to default 3

Here's assuming you mean "hide" by disable

<style type="text/css">

.disabled 
{
   display:none;
}
</style>


<img id='hrefId' src="/proteus/images/button_find.gif" alt="" />


<script languae="javascript">
var myPicture= document.getElementById('hrefId');
myPicture.className = "disabled";
</script>

Using jQuery, you can either hide the image : $("#hrefId").hide() or add a CSS class that would style it as being disabled : $("#hrefId").addClass("disabled")...

    document.getElementById('headname'+(t)).disabled=true;
            document.getElementById('headname'+(t)).setAttribute("class","disabledbo");
            document.getElementById('img'+(t)).src='../images/editfin.gif' ;
            document.getElementById('new'+(t)).src='../images/adds1.png' ;
            document.getElementById('new'+(t)).className = "disabled";
发布评论

评论列表(0)

  1. 暂无评论