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
3 Answers
Reset to default 3Here'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";