在使用clone()时id保持一致
大家都知道,同一个HTML页面中,不宜出现1个以上相同名称的id。但有时候需要使用jQuery框架的clone()来复制相同内容(附带样式),假如是使用了id号的获取方式,即$(‘#***’) 那么复制后得到新的内容也会把id号复制过来了,这时候就会出现一个页面出现2个或多个相同的id,比如:
<span style="font-family:SimSun;font-size:18px;">$('#single').click(function(){
$('#single-answer').clone(true).appendTo('#single-answer-null').show();
});
</span>
这时不妨添加一个变量来动态更改id的值,如:
<span style="font-family:SimSun;font-size:18px;">var oId = 1;
$('#single').click(function(){
$('#single-answer').clone(true).attr('id','single-answer'+oId).appendTo('#single-answer-null').show();
oId += 1;
});
</span>
这样就使得一个页面不会出现2个或多个相同的id名,保持了id的一致性。
在使用clone()时id保持一致的更多相关文章
- 触发器修改后保存之前的数据 表中插入数据时ID自动增长
create or replace trigger t before update on test5 for each rowbegin insert into test55 values (:old ...
- git clone时出现 error:inflate:data stream error(incorrect data check)
git clone时出现 error:inflate:data stream error(incorrect data check) fatal:serrious inflate inconsiste ...
- idea在使用git clone 时出现Filename too long
idea在使用git clone 时出现Filename too long的报错信息,使用如下命令就可以解决该问题:在 git bash命令模式下,运行命令 git config --global c ...
- git clone时加上--depth 1
当项目过大时,git clone时会出现error: RPC failed; HTTP curl The requested URL returned error: Gateway Time-out的 ...
- git clone 时注意点
环境: 在公司访问外网需要设置代理,另外,在公司局域网内架设了一台 GIT 服务器. 在使用 git clone 时,不能设置成 git 使用代理: git config --global http. ...
- Git clone时出现fatal:the remote end hung up unexpectedly
以HTTPS方式进行git clone时出现如下错误: 方法1:增大缓存 git config http.postBuffer 524288000 尝试无效: 方法2:配置git的最低速度和最低速度时 ...
- git clone时,报403错误,完美解决方案
首先命令行操作结果如下: root@zhiren-PowerEdge-T110-II:/zrun# git clone https://git.coding.net/xxxxxxxx/xxxx.git ...
- 创建触发器在表中播入数据时ID自动增长
),age )) create or replace trigger gger_tt before insert on ttt for each row when (new.id is null) b ...
- 使用windows 命令行执行Git clone时出现Host key error
由于是在java中执行cmd命令调用git clone,导致git读取不到用户的ssh key,需要设置环境变量Home为正确的用户路径: cmd /c set HOME=C:/Users/你的用户名 ...
随机推荐
- iOS逆向编程工具篇:class-dump
class-dump是用来dump目标对象的class信息的工具,利用OC的runtime特性,将存储在Mach-O文件中的@interface.@protocol信息提取出来,并生成对应的.h文件. ...
- FlowLayoutPanel控件控制里面子控件换行
// 摘要: // 设置值,该值表示的流中断设置 System.Windows.Forms.FlowLayoutPanel 控件. // // 参数: // control: // 子控件. // / ...
- Openwrt单独编译某一个模块而不是整个固件
make package/rt2860v2/compile 就是在make menuconfig那个目录下执行此命令就会编译rt2860v2这个模块
- 读取XML文档存入泛型List<T>集合中
前一篇博文是<泛型List<T>转存为XML文档> http://www.cnblogs.com/insus/p/3277410.html 把一个List<T>集合 ...
- html中img标签的url如何拼接变量
<img id="pic" /> <script type="text/javascript"> var url = "xxx ...
- day06.1-磁盘管理
1. 添加磁盘 打开虚拟机,依次点击"编辑虚拟机设置" |—> "添加" |—> "硬盘" |—> "选择硬盘类 ...
- day05.2-Vim编辑器
一. 安装Vim编辑器和打开新建文件 安装Vim编辑器:apt-get install Vim 新建与打开Vim文件:vim 文件名 二. Vim编辑器三种模式的使用与切换 指令 ...
- Ready api groovy script 参数化
def token_type =context.expand ('${#Project#token_type}') def access_token = context.expand('${#Proj ...
- Q的进阶用法
Q的实例化用法 #q1 里面的条件都是or的关系 q1=Q() q1.connector = 'OR' q1.children.append(('id',1)) q1.children.append( ...
- [翻译]CURAND Libaray--Host API--(1)
原文来自:cuda curand toolkit document Translated by xingoo 如果有错误请联系:xinghl90@gmail.com 2Host API简述 使用hos ...