1

トップナビゲーション、左ナビゲーションがあり、そのリンクはクリックされたトップナビゲーションリンクによって駆動され、ページ自体は左ナビゲーションとトップナビゲーションを備えたコンテンツコンテナの2列レイアウトです。

 <div id="topnav">Topic1 | Topic 2 | Topic 3</div>

    <div id="navigation">
      <!--all links from topic1 by default, or topic 2 links if topic 2 clicked-->
        <a href="home.html">Home</a>
        <a href="pictures.html">Picture</a>
    </div>
    <div id="content">
         <!-- content will load here -->
    </div>

トピック1をクリックすると、トピック1に属するすべてのリンクが左ナビゲーションに読み込まれ、画像をクリックすると、画像が#contentに読み込まれます。jqueryまたはjavascriptでこれを行うにはどうすればよいですか?ここで助けてください..jquery初心者..

4

2 に答える 2

0

HTML

<a class="loader" href="home.html">Link 1</a>
<div id="content"></div>

JavaScript(jQueryを使用)

$('a.loader').on('click', function(e) {
    e.preventDefault();
    $('#content').load($(this).attr('href'));
});

@Musaが言ったように、ロードするURLは自分のドメインにある必要があります。

于 2012-08-18T21:04:03.540 に答える
0

フレームを使用できます。

index.htm:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ca" lang="ca">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Site</title>
</head>
<frameset rows="100,*">
  <frame src="topnav.htm" name="topnav" />
  <frameset cols="300,*">
    <frame name="navigation" />
    <frame name="content" />
  </frameset>
</frameset>
</html>

topnav.htm:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Topnav</title>
</script>
</head>
<body>
<a href="topic1.htm" target="navigation">Topic 1</a> | 
<a href="topic2.htm" target="navigation">Topic 2</a> | 
<a href="topic3.htm" target="navigation">Topic 3</a> | 
</body>
</html>

topic1.htm:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Topic1</title>
</script>
</head>
<body>
<a href="content1-1.htm" target="content">Content 1</a> | 
<a href="content1-2.htm" target="content">Content 2</a> | 
<a href="content1-3.htm" target="content">Content 3</a> | 
</body>
</html>

そして、あなたの

  • content1-1.htm
  • content1-2.htm
  • content1-3.htm

topic2.htmとtopic3.htmについても同じようにします

于 2012-08-18T21:18:39.500 に答える