在使用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/你的用户名 ...
随机推荐
- Bulma 源码解析之 .container 类
Bulma 的 .container 类是这样实现的. .container position: relative // 不设置桌面以下设备的 container +desktop margin: 0 ...
- java 字符流 字节流
java对文本文档进行操作(拷贝.显示)出现乱码一般来说,可以从两个方面入手. 1.文本文件本身的编码格式. 2.java代码中处理文本文件的编码格式. 这里要注意的一点是,我们可以看出copyFil ...
- sonar Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar
背景: 今天在项目根目录执行maven sonar:sonar ,报错信息如下,然后就各种的搜,折腾了多半天天也没找出解决办法,最后打算放弃时,看到一遍文章说是mysql max_allowed_p ...
- iOS开发进制转换
1.十进制转换为二进制 /** 十进制转换为二进制 @param decimal 十进制数 @return 二进制数 */ + (NSString *)getBinaryByDecimal:(NSIn ...
- Go:创建新进程(os.StartProcess源码解读)
关于如何使用go语言实现新进程的创建和进程间通信,我在网上找了不少的资料,但是始终未能发现让自己满意的答案,因此我打算自己来分析这部分源代码,然后善加利用,并且分享给大家,期望大家能从中获得启发. 首 ...
- 算法训练 数字三角形(DP)
问题描述 (图3.1-1)示出了一个数字三角形. 请编一个程序计算从顶至底的某处的一条路 径,使该路径所经过的数字的总和最大. ●每一步可沿左斜线向下或右斜线向下走: ●1<三角形行数≤100: ...
- 【转】HTTP协议/IIS 原理及ASP.NET运行机制浅析【图解】
源地址:http://blog.csdn.net/chelen_jak/article/details/50040537
- 1、OpenCV Python 图像加载和保存
__author__ = "WSX" import cv2 as cv # 这里的文件是图片或者视频 def Save_File( image ): cv.imwrite(&quo ...
- html之表单和简单CSS
一.==表单== 1. form表单本身 <form name="myform" action="#" method="get"> ...
- python 字符串,bytes和hex字符串之间的相互转换
import binascii datastr='13'#string 类型转换为bytedataByte=str.encode(datastr)#byte串 转换为16进制 byte串 ,比如 b' ...