I am having an img inside <p> tag and if I click the img or the <p> it needs to be toggled and the img should changed.
I have done it by adding jQuery(this).attr("src", "img/hide.png"); but the img is not changing can any one suggest me the right path.
Here is my script:
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery(".content").hide();
//toggle the componenet with class msg_body
jQuery(".heading").click(function () {
jQuery(this).next(".content").slideToggle(500);
});
});
</script>
This is my CSS:
.layer1 {
margin: -5px;
padding: 0px;
width: 860px;
}
This is my markup:
<div class="layer1">
<p class="heading"><img src="img/show.png" alt="" style="margin:0 5px 0 0;" /></p>
<div class="content"></div>
<p class="heading"><img src="img/show.png" alt="" style="margin:0 5px 0 0;" /></p>
<div class="content"></div>
<p class="heading"><img src="img/show.png" alt="" style="margin:0 5px 0 0;" /></p>
<div class="content"></div>
<p class="heading"><img src="img/show.png" alt="" style="margin:0 5px 0 0;" /></p>
<div class="content"></div>
<p class="heading"><img src="img/show.png" alt="" style="margin:0 5px 0 0;" /></p>
<div class="content"></div>
</div>