Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add click event to Jquery UI accordian Header

When you create a Jquery UI accordian you get a bunch of headers, that when you click them a div opens. However, I would like to preform an additional action upon clicking the header.

How do i do this?

Any ideas?

Thanks!

like image 860
kralco626 Avatar asked Dec 20 '10 18:12

kralco626


2 Answers

Javascript

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

html

<h3 id = "CreateNewUserHeader"><a >Create New User</a></h3>
<div>some stuff</div>
like image 93
kralco626 Avatar answered Sep 21 '22 12:09

kralco626


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.

like image 23
Sarfraz Avatar answered Sep 19 '22 12:09

Sarfraz