I think you mean that you want want an onclick event that changes a class.
Here is the answer if someone visits this question and is literally looking to assign a class and it's onclick with JQUERY.
It is somewhat counter-intuitive, but if you want to change the onclick event by changing the class you need to declare the onclick event to apply to elements of a parent object.
HTML
<div id="containerid">
Text <a class="myClass" href="#" />info</a>
Other Text <div class="myClass">other info</div>
</div>
<div id="showhide" class="meta-info">hide info</div>
Document Ready
$(function() {
$("#containerid").on("click",".myclass",function(e){ /*do stuff*/ }
$("#containerid").on("click",".mynewclass",function(e){ /*do different stuff*/ }
$("#showhide").click(function() {changeclass()}
});
Slight Tweak to Your Javascript
<script>
function changeclass() {
$(".myClass,.myNewClass").toggleClass('myNewClass').toggleClass('myClass');
}
</script>
If you can't reliably identify a parent object you can do something like this.
$(function() {
$(document).on("click",".myclass",function(e){}
$(document).on("click",".mynewclass",function(e){}
});
If you just want to hide the items you might find it simpler to use .hide() and .show().