Hi All
I am trying to change an image onclick from a + image to a minus image, I have the following
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
function toggleDiv(divId) {
var hide = '<img src="images/icons/minus.png" />';
var show = '<img src="images/icons/plus.png" />';
$("#"+divId).toggle();
$('#myContent').load('tmpregister.php');
$('#openClose').text($('#openClose').text() == show ? hide : show);
}
</script>
<a id="openClose" href="javascript:toggleDiv('myContent');" style="padding: 5px 10px;">
<img src="images/icons/plus.png" />
</a>
<div id="myContent" style="background-color: #aaa; padding: 5px 10px; display:none;">
This works but changes the <> for the image to:
<img src="images/icons/plus.png" />
Thus breaking the HTML and the image does not show, although the toggle does happen onclick.
I have tried changing to use HTML rather than text:
$('#openClose').html($('#openClose').html() == show ? hide : show);
But that then stops the toggle of the image/text totally.
Can anyone help and point me to where I am going wrong.
Thanks
Matt