0

我在我的导航栏上使用 jquery,但我想让它在我的一个 div 标签中加载信息我需要添加到我的导航栏中的任何内容,该导航栏与 jquery/ajax 一起运行以加载到 div 中,我应该添加什么div 标签使其功能相同。我的网站是。

http://www.horimonotattoo.com

4

1 回答 1

0

我不完全确定您要达到的目标,但这也许会有所帮助。单击链接时,您可以使用 jQuery 在页面中添加 div,如下所示。

<head>
<!-- include jquery library -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

<!-- run a script for when a button or element is clicked -->
<script type="text/javascript">

//when page has loaded
$(document).ready(function() {
//when link with class name 'linkClassName' is clicked
    $('.linkClassName').click(function(){
    //add a div after the </a> tag
    $(this).append('<div>hello</div>');
});//end click function
});//end document ready

</script>

</head>

<body>

<a href="#" class="linkClassName">Click Me</a>

</body>

一个工作示例在这里http://jsfiddle.net/nskWD/1/

您还可以在 click 函数中使用 .load(url) 将整个页面加载到 div 中,

$('#divId').load(url);

于 2013-02-20T04:25:10.233 回答