<style type="text/css">
#second{
display:none;
}
</style>
On mouse event I want to pass id’s of div which is not related to current element from where I am calling the function.
<div id="first">
....
....
</div>
<div id="second">
....
....
</div>
<input type="image" src="..." id="notrelated"
onClick="f('first','second')"
/>
JavaScript
<script type="text/javascript" language="javascript">
function f(first,second){
document.getElementById(first).style.display='none';
document.getElementById(second).style.visibility='visible';
}
</script>
The above function thus helps in hiding and make the div visible which is based on mouse event on image.
I followed these above steps,after making visibility ‘visible’ it wont show because I’ve made div second display none and I tried making the following changes which results in second div occupying space which I don’t prefer:
<style type="text/css">
#second{
visibility:hidden;
}
</style>
If I got your question, you just want to pass your div ids in the function. So you can easily pass it in any function.
Like
and your js function will work
But If you want that only passing these id you want to toggle these, then you should change your function to like
You can check this DEMO