| SitePoint Sponsor |


Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript




Can you please help me on the load statement.i think i am lostIf you are planning to load the content from an external file, you don't need anything in the content area to start with. You can just leave that content area empty.
Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title>Index</title> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $("div#menu").on("click","a",function(event) { event.preventDefault(); $("div#menu a").each(a.attr("href")) { $("div#content").load($(this)); } }); }); </script> </head> <body> <div id="menu"> <ul> <li class="header">My menu</li> <li><a href="page1.php"><span>Search name<span></a></li> <li><a href="page2.php"><span>Search fname<span></a></li> <li><a href="page3.php"><span>Search lname<span></a></li> </ul> </div> <div id="content"> </div> </body> </html>


You don't need that each method now, because you're not needing to hide anything. The load method replaced the entire content area with what comes from the linked file.
So you would want to use something like this:
Code javascript:var file = $(this.href); $("#content").load(file);
Or you could get rid of the variable and do something like this:
Code javascript:$("#content").load($(this.href));
Personally I prefer the first example, because it's easier to at a glance, understand at what is going on there.
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript




you mean thisPersonally I prefer the first example, because it's easier to at a glance, understand at what is going on there.
var file = $(this.href);
$("#content").load(file);


Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript




sorry i was disconnected




is this okay without putting the div?var file = $(this.href);
$("#content").load(file);
var file = $(this.href);
i mean like this $("div#content").load(file);


Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript




It's working now..hehehehehe..thank you so much for helping me...by the ways in your post #2 is this also the same effect?




still there???


Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript


Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript




I do apologize...Thank you so much for helping me and for the idea that you share...more power to you always.This is not a live chat. It's an internet forum which doesn't involve live conversations. Forums are less like telephone calls or text messaging, and more like sending emails.
Bookmarks