首页 技术 正文
技术 2022年11月19日
0 收藏 404 点赞 3,973 浏览 825 个字

概述:

  先上我的布局图:jquery-动态设置ul li a链接目标

  ul中的每一个li里面包含着一个’a’超链接,可以猜想到,我想没点击ul->li里面每个a,链接到不同的页面,在这里,我用iframe完成.

html主要代码为:

 <div class="warp">
<div class="title">
<ul id="fengcai_title">
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" >教师的风采1</a></li>
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" >教师的风采2</a></li>
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" >教师的风采3</a></li>
</ul>
</div>
<div class="content">
<iframe scrolling="auto" target="_parent" id="content_frame" src="content/tar.html"> </iframe>
</div>

  然后下载相关的jquery库,完整的jquery代码为:

<script type="text/javascript" src="jq/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="jq/jquery-2.1.0-vsdoc.js"></script>
<script type="text/javascript" src="jq/jQuery2.1.js"></script>
<script type="text/javascript" >
function dd() {
$("#fengcai_title li a").click(function(){
$("#content_frame").attr('src', 'content/' + this.innerHTML + ".html");
});
}
</script>

  其中,页面文件统一放在’content’目录中,页面的文件名和 a中的文字相对应.可以在 body的onload事件中调用该dd()函数.

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,023
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,513
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,361
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,143
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,774
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,853