?
Solved

Jquery click doesn't work

Posted on 2014-09-19
5
Medium Priority
?
137 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

DOM Attributes and Properties treatment with jQuery 1.6 by Ivo Stoykov jQuery (http://jquery.com/) 1.6 introduces .prop() (http://api.jquery.com/prop/) and .removeProp() (http://api.jquery.com/removeProp/) methods which allow modifying or removi…
What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
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

719 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