开发者

Show DIVs with greatest value

Ok, so I'm making a "tip of the week" slider. Basically it's for my client, which is the reason I'd need to simplify the posting process as much as possible.

Right now it is just a slider for 4 divs: http://juuso.kivinen.org/tofw/ That is n开发者_开发技巧ot the most recent version, because I haven't had time to update it yet(server ver.).

So basically(sorry for the long intro) my question is: How can I make jquery load the first 4 divs from an external html file? Or should I move to php?

The basic structure of my code would be:

<div id="slider">
 <div id="row">
  <div id="EXTERNAL CONTENT1"></div>
 </div>
<div id="row">
 <div id="EXTERNAL CONTENT2"></div>
</div>
<div id="row">
 <div id="EXTERNAL CONTENT3"></div>
</div>
<div id="row">
 <div id="EXTERNAL CONTENT4"></div>
</div>
</div>


This can be done using lt() and load():

$('#container').load('path/to/page.html #divContainer div:lt(4)');

Demonstration of concept: http://davidrhysthomas.co.uk/play/loadDemo2.html (original version: http//:davidrhysthomas.co.uk/play/loadDemo.html).


I hope you have set up some code in your server to serve the EXTERNALCONTENT

then

$.get("urlToGetEXTERNALCONTENT",function(data){
$("#EXTERNALCONTENT4").html(data);
});


You can use the ".load()" method to pluck content out of a loaded document. In your case:

$('#placeToPutStuff').load(yourUrl + ' #slider', function() { /* ... */ });


Without more information a complete answer isn't possible, but you should look at the .load() method for jQuery. You are able to load partial sections of external files. http://api.jquery.com/load/

for example:

$('#EXTERNAL_CONTENT1').load('tips.html #external1')

What will the structure of the file you want to load from look like? Is your client going to be continually appending to that file?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜