How to show/hide the image on clicking the hyperlink?
<script>
function getresource(id)
{
if(id==4)
{
//show image
}
else if(id==5)
{
//hide image
}
}
</script>
<a href="#" onclick="javascript:getresource('4');">Bandwidth</a>
<a href="#" onclick="javascript:getresource('5');">Upload</a>
<p align="center">
<img id="img3" src="/media/img/close.png" style="visibility: hidden;" />
<img id="img4" src="/media/img/close.png" style="visibility: hidden;" />
</p>
If you're trying to hide upload img and show bandwidth img on bandwidth click and viceversa this would work
What image do you want to hide? Assuming all images, the following should work:
Otherwise, using selectors, you could find all images that are child elements of the containing div, and hide those.
However, i strongly recommend you read the Jquery docs, you could have figured it out yourself: http://docs.jquery.com/Main_Page
I know this is an older post but it may be useful for those who are looking to show a .NET server side image using jQuery.
You have to use a slightly different logic.
So, $("#<%=myServerimg.ClientID%>").show() will not work if you hid the image using myServerimg.visible = false.
Instead, use the following on server side:
Use the
.css()
jQuery manipulators, or better yet just call.show()
/.hide()
on the image once you've obtained a handle to it (e.g.$('#img' + id)
).BTW, you should not write javascript handlers with the "javascript:" prefix.
With image class name:
With image Id :