Solved

Jquery click doesn't work

Posted on 2014-09-19
5
133 Views
Last Modified: 2014-09-19
Hello,

See this: http://rkassoc.org/Davis/menu/menu_testb.htm. Note that if you click Irrigation (top item) or Landscape (bottom item), it paints a submenu; then if you click the gold "<", it goes back.. Code attached.

See http://rkassoc.org/Davis/index10.htm. The same menu (& I believe same jquery functions) are included in this file. Note the click on Irrigation or Landscape produces nothing.

Code attached.

Why does it work in one case & not the other?

Thanks
index10.htm
menu-testb.htm
0
Comment
Question by:Richard Korts
  • 2
  • 2
5 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40333477
The HTML is dynamic so you have to add a listener
e.g.
$(document).on("click","#irr",function() {
0
 

Author Comment

by:Richard Korts
ID: 40333572
To Gary,

I did that, still doesn't work;
__________________________________
<script>
$(function () {
    $(document).on("click","#irr",function()  {
          $('#menu').html('<li><span style="color: #5A63E7;">></span> Sprinkler</li><li><span style="color: #5A63E7;">></span> Drip / Low Volume</li><li><span style="color: #5A63E7;">></span> Pumps</li><li><span style="color: #5A63E7;">></span> Water Management</li>');
              $('#goback').html('<span style="background-color:black; white-space: nowrap; cursor: pointer;"><</span>');
    });
      $(document).on("click","#goback",function()  {
            location.reload();
      });
      $(document).on("click","#lsc",function()  {
          $('#menu').html('<li><span style="color: #5A63E7;">></span> Evaporative Cooling</li><li><span style="color: #5A63E7;">></span> Decks & Structures</li><li><span style="color: #5A63E7;">></span> Geotextile Fabrics</li><li><span style="color: #5A63E7;">></span> Tools</li>');
              $('#goback').html('<span style="background-color:black; white-space: nowrap; cursor: pointer;"><</span>');
    });      
});      
</script>
___________________________________

http://rkassoc.org/Davis/index10.htm
0
 
LVL 58

Expert Comment

by:Gary
ID: 40333590
Is there any reason to be using an old version of jQuery?
Didn't realise it was old so you would need to use .live()
http://api.jquery.com/live/

$("#irr").live("click",function()  {
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40333683
remove this block :
<script>
$(function () {
});	
</script>

Open in new window


and replace :
$("#includedContent").load("b.html");
by :
$("#includedContent").load("b.html", function() {

// WE PUT IT HERE ONCE THE MENU IS LOADED

    $('#irr').click(function() {
          $('#menu').html('<li><span style="color: #5A63E7;">></span> Sprinkler</li><li><span style="color: #5A63E7;">></span> Drip / Low Volume</li><li><span style="color: #5A63E7;">></span> Pumps</li><li><span style="color: #5A63E7;">></span> Water Management</li>');
		  $('#goback').html('<span style="background-color:black; white-space: nowrap; cursor: pointer;"><</span>');
    });
	$('#goback').click(function() {
		location.reload();
	});
	$('#lsc').click(function() {
          $('#menu').html('<li><span style="color: #5A63E7;">></span> Evaporative Cooling</li><li><span style="color: #5A63E7;">></span> Decks & Structures</li><li><span style="color: #5A63E7;">></span> Geotextile Fabrics</li><li><span style="color: #5A63E7;">></span> Tools</li>');
		  $('#goback').html('<span style="background-color:black; white-space: nowrap; cursor: pointer;"><</span>');
    });	

// END

          
});

Open in new window

0
 

Author Closing Comment

by:Richard Korts
ID: 40333725
Excellent, you are a Jquery expert for SURE!
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
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…

825 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