あなたがAJAXを使用して、データベースまたは別のWebサイトや他のウェブページのうち、このデータを取得する必要があります動的なコンテンツを取得するために。私は読んで、learning JQueryはかなりシンプルで他の言語と同様に、論理的な流れに従うことをお勧めします。 JQueryの構文も非常にシンプルなので、あまりにも難しくはありません。しかし、私は逃げる。
次のようにHTMLの構造がある場合:
<div id="container">
<div id="panel1" class="panel">
<a href="#" class="button" id="btn-1">Button 1</a>
<div id="iframe-1"></div>
</div>
<div id="panel1" class="panel">
<a href="#" class="button" id="btn-2">Button 2</a>
<div id="iframe-2"></div>
</div>
<div id="panel1" class="panel">
<a href="#" class="button" id="btn-3">Button 3</a>
<div id="iframe-3"></div>
</div>
</div>
とあなたのCSSは、おおよそ次のようになります。
はJQueryを使用して
.panel{
float:left;
}
/* Initially hide all iframe divs */
.panel > div{
display:none
}
/* Initially show only the first iframe div */
.panel > div:first-child{
display:block;
}
、あなたが使用することができます。
と同様に
//Run the code after the elements of the page have been downloaded. This is usually how most JQuery syntax starts.
$(document).ready(function(){
//When the button is clicked, run a function
$('.button').click(function(e){
e.preventDefault(); //Prevents default click behavior; similar to defining onclick='return false;' in the <a /> tag.
$('.button').siblings('div').hide(); //Hide all open iframe divs
$(this).siblings('div').show(); //Show the iframe div corresponding to clicked link
var id = $(this).attr('id').replace('btn-','iframe-'); //Get the ID of the link clicked and replace 'btn-' with 'iframe-'
$('#'+id).load('http://<url of the page you want to load>'); //Load the new web page or content into the iframe div. This could be an absolute or relative path.
});
});
.load()の機能には、.ajax()という機能もあります包括的なまた、Javascriptの仕組みは、クライアントコンピュータでコンパイルされ、ページが読み込まれたときに一度実行されることです。したがって、ページのHTMLに追加されている動的データを取得する場合、クリック、ホバーなどのアクションは、新しいコンテンツに対してリロードする必要があります。 JQueryの.on()イベントまたは.delegate()イベントを使用する必要があります。
これが役に立ちます。
あなたが始めたデザイン/レイアウトやサンプルHTMLはありますか?人々はあなたのために全部を行うよりも、あなたが仕上げるのを助ける可能性が高いです。 –
私はレイアウトがはいっており、私も行くにつれて自分のサイトを構築しています。私は基本的に、私が望むサイズやものを持っています、私はちょうどコーディングスタイルやそれを実行する方法を知らない。上記の編集済みの記事を参照してください。 – H4R73Y
jsfiddle.netに例を投稿し、ここにURLを投稿してください。 –