add click event to Jquery UI accordian Header

Javascript

$("#CreateNewUserHeader").click(function() {
    alert("test");
});

html

<h3 id = "CreateNewUserHeader"><a >Create New User</a></h3>
<div>some stuff</div>

You need to wrap your code in ready handler:

$(function(){
  $("#CreateNewUserHeader").click(function() {
    alert("test");
  });
});

Also make sure that you do not assign same id to more than one elements.


What I've done when I needed to do this in the past was something like this:

$('#accordion h3 a').bind('click', function (e) {
  // bind to the the header / anchor clicks
  if (!condition) {
    e.preventDefault();
    e.stopPropagation();
  }
});