js变量在属性里的写法 常用mark 多个DL遍历添加一个父级DIV
标记用
js变量比如url链接一般都是a里面的href属性值 在js里单引号链接 以后再忘记就能有地方找了
例子:
/*
添加1200 居中div 包裹 获取元素集合 上层元素100%
* @ele 改变元素
* @index 元素索引
* @color 100% 背景颜色
* */
function addW100Bg(ele,index,color,url){ /*获取list-bar*/
$bar= $(ele).eq(index).html();
/*设置list-bar*/
$(ele).eq(index).html('<div style="width: 1200px; margin: 0px auto; overflow: hidden;">'+'<a href='+url+ ' target="_blank">'+$bar+'</a>'+'</div>');
$(ele).eq(index).css({"width":"100%","background":color}); }
addW100Bg(".list-bar",0,"#e1ebf4","http://www.no5.com.cn/brandstore-291.html");
下面就是常用的 单位里经常要操作DOM 页面模板 不过定的很死
<div class="list-box"> <div class="list-bar"></div> <dl>......</dl> <dl>......</dl> <div class="list-bar"></div> <dl>......</dl> <dl>......</dl> ....... </div>
只能动态的添加DOM元素来改变页面
要的效果就是中间1200px居中 1200下面的img添加a跳转 父级100% 第一个函数实现的就是这个效果
太麻烦了 直接把JS所有的都贴上来 省得以后找不到
var ClsSpecialTopicAdditionalJS = function () {
//
function marginleft(){
var num = $('.prod-box').length;
for(i=0;i < num;i++){
if(i % 4 == 0){
$('.prod-box').eq(i).css({"marginLeft":"60px"} );
}
}
}
marginleft();
function addAfter(){
/*头部*/
var head='<div class="w100" id="head">' +
'<div class="w1200">' +
'<div class="banner-img"><img src="http://photo.no5.com.cn/publish/minganji/free_02.jpg" width="1200" height="481" alt=""/></div>' +
' <ul id="nav-fix">' +
'<li><a href="#s1" target="_self"><img src="http://photo.no5.com.cn/publish/minganji/free_04.jpg" width="131" height="84" alt=""/></a></li>' +
' <li><a href="#ss0" target="_self"><img src="http://photo.no5.com.cn/publish/minganji/free_05.jpg" width="131" height="84" alt=""/></a></li>' +
' <li><a href="#ss1" target="_self"><img src="http://photo.no5.com.cn/publish/minganji/free_06.jpg" width="134" height="84" alt=""/></a></li>' +
'<li><a href="#ss2" target="_self"><img src="http://photo.no5.com.cn/publish/minganji/free_07.jpg" width="126" height="84" alt=""/></a></li>' +
'<li><a href="#ss3" target="_self"><img src="http://photo.no5.com.cn/publish/minganji/free_08.jpg" width="129" height="84" alt=""/></a></li>' +
'<li><a href="#ss4" target="_self"><img src="http://photo.no5.com.cn/publish/minganji/free_09.jpg" width="134" height="84" alt=""/></a></li>' +
'<li><a href="#ss5" target="_self"><img src="http://photo.no5.com.cn/publish/minganji/free_10.jpg" width="134" height="84" alt=""/></a></li>' +
'<li><a href="#ss6" target="_self"><img src="http://photo.no5.com.cn/publish/minganji/free_11.jpg" width="136" height="84" alt=""/></a></li>' +
'<li><a href="#ss7" target="_self"><img src="http://photo.no5.com.cn/publish/minganji/free_12.jpg" width="145" height="84" alt=""/></a></li>' +
'</ul>' +
'<a href="http://www.no5.com.cn/product/4603.html" target="_blank">' +
'<img src="http://photo.no5.com.cn/publish/minganji/free_14.jpg" width="262" height="434" alt="" id="s1"/></a>' +
'<a href="http://www.no5.com.cn/product/22278.html" target="_blank">' +
'<img src="http://photo.no5.com.cn/publish/minganji/free_15.jpg" width="360" height="434" alt=""/></a>' +
'<a href="http://www.no5.com.cn/product/24533.html" target="_blank">' +
'<img src="http://photo.no5.com.cn/publish/minganji/free_16.jpg" width="283" height="434" alt=""/></a>' +
'<a href="http://www.no5.com.cn/product/17734.html" target="_blank">' +
'<img src="http://photo.no5.com.cn/publish/minganji/free_17.jpg" width="295" height="434" alt=""/></a>' +
'<a href="http://www.no5.com.cn/product/27606.html" target="_blank">' +
'<img src="http://photo.no5.com.cn/publish/minganji/free_18.jpg" width="262" height="422" alt=""/></a>' +
' <a href="http://www.no5.com.cn/product/19867.html" target="_blank">' +
'<img src="http://photo.no5.com.cn/publish/minganji/free_19.jpg" width="360" height="422" alt=""/></a>' +
'<a href="http://www.no5.com.cn/product/7576.html" target="_blank">' +
' <img src="http://photo.no5.com.cn/publish/minganji/free_20.jpg" width="288" height="422" alt=""/></a>' +
'<a href="http://www.no5.com.cn/product/23832.html" target="_blank">' +
'<img src="http://photo.no5.com.cn/publish/minganji/free_21.jpg" width="290" height="422" alt=""/></a>' +
'</div>' +
' </div>';
$(".banner-box").after(head);
}
addAfter();
function addJumpID() {
for (i = 0, ii = $('.list-bar').length; i < ii; i++) {
$('.list-bar').eq(i).attr({"id": "ss" + i, "name": "ss" + i})
}
}
addJumpID();
$(window).scroll(
function(){
if( $(window).scrollTop() > 700||$(document).scrollTop() > 700){
$('#nav-fix').css({"position":"fixed","top":"0px","z-index":"999"});
}else{
$('#nav-fix').css({"position":"relative","top":"0px","z-index":"999"});
}
}
)
/*
指定元素集合 添加父级元素
* @ele 获取元素
* @stat 开始位置
* @end 结束位置
* @return html element */
function addW1200(ele,star,end){
var content = $(ele).slice(star,end).wrapAll('<div style="width: 1200px; overflow: hidden; margin: 0px auto;"></div>');
}
addW1200(".prod-box",0,8);
addW1200(".prod-box",8,16);
addW1200(".prod-box",16,24);
addW1200(".prod-box",24,32);
addW1200(".prod-box",32,40);
addW1200(".prod-box",40,44);
addW1200(".prod-box",44,52);
addW1200(".prod-box",52,59);
/*宽度改变100%*/
function addW100(ele){
$box = $(ele).eq(0).html();
$(ele).eq(0).html('<div style="width:100%; margin: 0px auto; overflow: hidden;">'+$box+'</div>');
$(ele).eq(0).css({"width":"100%"});
}
addW100(".list-box");
/*
添加1200 居中div 包裹 获取元素集合 上层元素100%
* @ele 改变元素
* @index 元素索引
* @color 100% 背景颜色
* */
function addW100Bg(ele,index,color,url){
/*获取list-bar*/
$bar= $(ele).eq(index).html();
/*设置list-bar*/
$(ele).eq(index).html('<div style="width: 1200px; margin: 0px auto; overflow: hidden;">'+'<a href='+url+ ' target="_blank">'+$bar+'</a>'+'</div>');
$(ele).eq(index).css({"width":"100%","background":color});
}
addW100Bg(".list-bar",0,"#e1ebf4","http://www.no5.com.cn/brandstore-291.html");
addW100Bg(".list-bar",1,"#c2e3f8","http://www.no5.com.cn/brandstore-44.html");
addW100Bg(".list-bar",2,"#f2f7f9","http://www.no5.com.cn/brandstore-267.html");
addW100Bg(".list-bar",3,"#e5f8fc","http://www.no5.com.cn/brandstore-986.html");
addW100Bg(".list-bar",4,"#d7ebf4","http://www.no5.com.cn/brandstore-684.html");
addW100Bg(".list-bar",5,"#eaeaea","http://www.no5.com.cn/brandstore-1258.html");
addW100Bg(".list-bar",6,"#ffffff","http://www.no5.com.cn/brandstore-42.html");
addW100Bg(".list-bar",7,"#ffffff","http://www.no5.com.cn/brandstore-950.html");
/*父元素下的子元素删除
* @parent 父级元素
* @son 删除的子元素
* */
function eleRemove(parent,son){
$(parent).find(son).remove();
}
eleRemove(".nav-layer","ul");
//
}
写法好糟糕了 希望大神看到能指点一二
js变量在属性里的写法 常用mark 多个DL遍历添加一个父级DIV的更多相关文章
- 利用CSS背景颜色属性使父级div背景透明同时避免子级标签透明。
实现背景色透明效果的代码 实现各个浏览器中具备良好的透明特性的效果,IE中使用私有滤镜filter,高端浏览器使用CSS3中的rgba属性. 输入十六进制的颜色值以及透明度,自动在IE的过渡滤镜以及C ...
- Js变量定义——fn里 var与不var的区别
js运行时内置了一个Global对象. 这个Global对象跟运行环境有关.在浏览器运行环境中.Global就是window对象.在nodejs中.Global对象是global对象. 当你在浏览器环 ...
- HTML识别后台传输或者js变量中字符串里的 '\n' 并成功换行显示
HTML识别 string 里的 '\n' 并成功换行显示 设置标签的的css属性 white-space: pre-line; <div style='white-space: pre-lin ...
- js 变量与属性的区别
在全局作用域下, 表明全局变量x,属性b,都是window的属性,因为在全局作用域下,浏览器默认会创建一个window对象. 说明变量x不能通过delete进行删除,但是属性y可以通过delete进行 ...
- 练习2 练习目标-使用引用类型的成员变量:在本练习中,将扩展银行项目,添加一个(客户类)Customer类。Customer类将包含一个Account对象。
package banking; public class Customer { private String firstName; private String lastName; private ...
- JS关闭当前父级div
代码: <img src="img/diagram.png" onclick="javascript:this.parentNode.parentNode.remo ...
- js动态绑定class(当前父级div下的子元素有没有这个class,有的话移除,没有的话添加)
<div class="layui-inline" id=‘’ onclick="changeType(id)"> ...
- Objective-C Runtime 运行时之二:成员变量与属性(转载)
在前面一篇文章中,我们介绍了Runtime中与类和对象相关的内容,从这章开始,我们将讨论类实现细节相关的内容,主要包括类中成员变量,属性,方法,协议与分类的实现. 本章的主要内容将聚集在Runtime ...
- jsp中把js变量赋给java变量,或者将java变量赋给js变量怎么做?
在jsp中经常会遇到把js变量赋给java变量,或者将java变量赋给js变量的情况,在此将通用的处理方法小结如下: java变量传给js好办,var a=”<%=javaParam%>“ ...
随机推荐
- zoj3261 并查集离线处理
Connections in Galaxy War Time Limit:3000MS Memory Limit:32768KB 64bit IO Format:%lld & ...
- 使用kuernetes提供高可用的logstash服务
在kubernetes集群中部署logstash步骤如下: 1:logstash安装文件(目前最新版本2.3.4): 2:编写Dockerfile及执行点脚本文件run.sh,并且修改logstash ...
- python 列表与元组的操作简介
上一篇:Python 序列通用操作介绍 列表 列表是可变的(mutable)--可以改变列表的内容,这不同于字符串和元组,字符串和元组都是不可变的.接下来讨论一下列表所提供的方法. list函数 可以 ...
- jquery插件-表单验证插件
JQuery 插件概述: 插件(plugin)也被成为扩展,是一种遵循一定规范的应用程序编写出来的程序,JQuery有大量 现成的插件. 一句话,JQuery插件就是别人依照Jquery官方规范写好的 ...
- 【bzoj1178】 Apio2009—CONVENTION会议中心
http://www.lydsy.com/JudgeOnline/problem.php?id=1178 (题目链接) 题意 给出n个区间,问在区间两两不相交的情况下最多能选出多少区间,并输出字典序最 ...
- CruiseControl.NET/CCNET配置(SVN+MSBuild+BAT+FTP)
CCNET目前最新版本为1.8.5,官方很久没更新过了,如果投入生成环境使用,建议全部转到Jenkins上. 可以直接在这里下载:http://www.cnblogs.com/EasonJim/p/5 ...
- 推荐一个学习golang的地址
链接打开后,文字可以点击! http://yougg.github.io/static/gonote/GolangStudy.html#
- ecshop /api/client/api.php、/api/client/includes/lib_api.php SQL Injection Vul
catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 ECShop存在一个盲注漏洞,问题存在于/api/client/api. ...
- C# ref的应用
之前一直只是知道有这么个参数修饰符,也知道用来干嘛的,但是基本就没用上.这几天好好整理了一下,发现ref的修饰符可以帮助简化很多代码.让我更深入的了解到面向对象的深沉含义. 自定义一个类中,类中的方法 ...
- Unity3d5.0 新UI之2048
因为汽车系统没写出来所以,纠结之中,弄了弄新版本的UI. 做了个2048. 新版本的unity的UI必须以Canvas为基底来呈现,如果没有加画布的话可是显示不出来东西的哦. 而且作为UI上的所有组件 ...