javascript - How to target a div<> with a link, using php? -


what's best way target particular <div> selection menu using php?

specifically, want have link selected menu contained in div id=menu loaded in div id=content.

i can see has been discussed in here, can't seem find clear answer. so, apologies if rehashing old topic, gather need use ajax this, or can done php only? there examples or tutorials available?

thanks

you'll need ajax , bit of magic.

html

<div id="menu"><a href="page.html">page 1</a> | <a href="page2.html">page 2</a></div> <div id="content"></div> 

javascript (with jquery)

$("#menu a").each(function(e){      $(this).bind("click", function(event){          $("#content").load($(event.target).attr("href"));     }); }); 

i haven't tested this, should work. want bind links within #menu , when 1 clucked load href #content via ajax call.


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -