How to set an onClick attribute that would load dynamic content?

Posted by konzepz on Stack Overflow See other posts from Stack Overflow or by konzepz
Published on 2010-03-26T13:32:05Z Indexed on 2010/03/26 13:43 UTC
Read the original article Hit count: 208

Filed under:
|
|
|

This code is suppose to add an onClick event to each of the a elements, so that clicking on the element would load the content of the page dynamically into a DIV.

Now, I got this far - It will add the onClick event, but how can I load the dynamic content?

$(document.body).ready(function () {
  $("li.cat-item a").each(function (i) {
      this.setAttribute('onclick','alert("[load content dynamically into #preview]")');
  });
});

Thank you.

© Stack Overflow or respective owner

Related posts about js

Related posts about jQuery