在使用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/你的用户名 ...
随机推荐
- PersonDto中@ResourceAccess(readOnly = true)以及swagger的理解-----似懂非懂,日后消化
@JsonApiResource(type = PersonDto.RESOURCE_TYPE) @EntityMapping(entityClass = Person.class) //@Resou ...
- SDUT 3402 数据结构实验之排序五:归并求逆序数
数据结构实验之排序五:归并求逆序数 Time Limit: 40MS Memory Limit: 65536KB Submit Statistic Problem Description 对于数列a1 ...
- Java泛型读书笔记 (一)
Java泛型 在Java SE7和之后的版本中,在new一个泛型类实例的时候,可以不传入类型参数,因为Java编译器可以通过赋给的变量类型声明推断出来,如下代码: ArrayList<Strin ...
- C/C++中char* p = "hello" 和 const char* p = "hello"的区别
在写代码常常都会写char * p ="hello";这样的代码,虽然不是错误,但却不建议这样用.应该加const修饰.这句话背后的内涵是什么?下面就刨根问底一下:) 这个行为在不 ...
- android报错:org.ksoap2.SoapFault cannot be cast to org.ksoap2.serialization.SoapObject
今天在写一个webservice时一直报错,报Caused by: java.lang.ClassCastException: org.ksoap2.SoapFault cannot be cast ...
- 1003. Check If Word Is Valid After Substitutions
We are given that the string "abc" is valid. From any valid string V, we may split V into ...
- Jmeter-逻辑控制器之Switch控制器(Switch Controller)
Switch控制器(Switch Controller): 作用:Switch控制器通过给该控制器中的Value赋值,来指定运行哪个采样器.有两种赋值方式: 第一种是数值,Switch控制器下的子节点 ...
- P3345 [ZJOI2015]幻想乡战略游戏 动态点分治
\(\color{#0066ff}{ 题目描述 }\) 傲娇少女幽香正在玩一个非常有趣的战略类游戏,本来这个游戏的地图其实还不算太大,幽香还能管得过来,但是不知道为什么现在的网游厂商把游戏的地图越做越 ...
- vue项目中使用了vw适配方案,引入第三方ui框架mint-ui时,适配问题解决
问题分析: 一般第三方ui框架用的都是不同的适配方式,如果我们使用了vw适配,那么在使用mint-ui框架时,就会发现px单位会被转换成vw,从而导致样式变小的问题,如图 解决方案 网上看到了很多种解 ...
- 【STL基础】list
list 构造函数: //default: list<T> l; //空的list //fill: list<T> l(n); //n个元素, 元素默认初始化 list< ...