I'm a beginner with Jquery, I've managed to get a button to show the div and the button to move to the right when the div is shown. I've seen similar questions for toggling visibility, etc but I also need to move the button on click but I have tried to follow their logic to get it to work with no success.
But when I do the opposite for when it's clicked again (hide the div and move the button back) I can't get it to work.
Can someone tell me where I'm going wrong?
Html
<button id="myfilterFunction">Show/Hide</button>
<div id="filterview">
<?php echo $column_right; ?></div>
</div>
Javascript
<script>
$( "#myfilterFunction" ).click(function() {
if ($( "#filterview" ).css('display', 'none')) {
$('#filterview').show();
$( "#myfilterFunction" ).css('margin-left', '300px');
}
if ($( "#filterview" ).css('display', 'block')) {
$('#filterview').hide();
$( "#myfilterFunction" ).css('margin-left', '0');
}
});
</script>