jQuery linking jquery on calling page to page called using .load()

Posted on 2011-10-13
Medium Priority
Last Modified: 2012-08-13
Hello Experts,

Please see this example:

This file calls test2.html and loads it into the div.
I have some simple jquery  in test1.html that I want executed when the user clicks a checkbox.
The jquery calls an alert and then populates a counter with the checkbox name.

For example, if you click on '1' at the top of the tree, I expect the alert to say '_44 clicked'
and _44 to appear on the form (I have just put an empty div next to _1 for this example).
In practice, I will create empty divs next to each checkbox in my tree.

My main question is:
Why isn't the jquery being recognised?
How can this be fixed?

Many Thanks!
Question by:jagku
  • 2
LVL 83

Expert Comment

ID: 36964038
Use :

$(function() {
   $('div.test').load('test2.html', function() {

      $('input[name^=_]').click(function() {
            var id = $(this).attr("name");
          alert(id + ' clicked');



check here the second load's parameter : http://api.jquery.com/load/

LVL 83

Accepted Solution

leakim971 earned 2000 total points
ID: 36964043
Using : http://api.jquery.com/live/

It should work too :

<script type="text/javascript">

$(function() {


	$('input[name^=_]').live("click",function() {

		var id = $(this).attr("name");

	    alert(id + ' clicked');





Open in new window


Author Closing Comment

ID: 36966922
Many Thanks (as usual!)

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question