I need to change a class .author to .authornew when I click.
my html:
<div class="meta-info" id="showhide">
<div class="author"></div>
<div id="author-dropdown" style="display: none;"></div>
My script:
<script>
$(document).ready(function() {
$('#showhide').click(function() {
if($('#author-dropdown').css('display') == 'none') {
$('#author-dropdown').attr("id","author-dropdown-extended").slideDown();
} else {
$('#author-dropdown-extended').attr("id","author-dropdown").slideUp();
}
return false;
});
});
</script>
#showhide is the id to press on. #author-dropdown is the drop down content. Now, the script changes id of drop down content, but I actually need to change class .author to .authornew. How should I amend my script to do this? Thanks!
This should do the trick!
First it removes the author class of your div with class author, and it then adds the class authornew to the object.