When you create the jQuery user interface, you get a bunch of headers that clicking on them opens a div. However, I would like to perform an additional action after clicking on the title.
How should I do it?
Any ideas?
Thank!
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 a handler ready:
ready
$(function(){ $("#CreateNewUserHeader").click(function() { alert("test"); }); });
Also make sure that you do not assign the same identifier to multiple elements.
, , , :
$('#accordion h3 a').bind('click', function (e) { // bind to the the header / anchor clicks if (!condition) { e.preventDefault(); e.stopPropagation(); } });
, , , , .
https://api.jqueryui.com/accordion/#event-activate
$( ".selector" ).accordion({ activate: function( event, ui ) {} });