jquery html拼接标签的显示和隐藏

关于html 脚本的拼接,实现隐藏和显示。

本人对jQuery的理解不是很深刻,如果感觉说得有问题(或不清楚)的地方请更正。

因为对页面有时候比较复杂,我拿到数据以后的操作都需用js处理

html 的div table span 都是拼接出来的

如果想让脚步隐藏或显示,用经典的jQuery 的hide 和 show 方法不能实现,但是通过调试发现

如果样式修改就可以显示出来(或是隐藏),这时候jQuery 的css 就可以实现这个功能了。

var tablestr='<br /><table class="table table-striped table-bordered" style="fontsize:12px;" align="center"><tbody>'+
'<tr><td width="20%">交易时间</td></tr>'+
'<tr><td><span id="insert" style="cursor:pointer;" onclick="echange(1)">'+detail['insertTime'].substr(0, 19)+'</span><span id="target" style="display:none;"><input type="text" style="70px" id="input"></input><input type="button" onclick="echange(2)" value="修改"></input></span></td></tr>'+
'</tbody></table>';

function echange(type){
if(type==1){
$("#doposconsumeinsert").css("display","none");
$("#doposconsumetarget").css("display","block");
}
else{
$("#doposconsumeinsert").css("display","block");
$("#doposconsumetarget").css("display","none");
}
}

以上脚本只是一个思路,不一定100%能执行成功。

原文地址:https://www.cnblogs.com/tianzhiyun/p/4672676.html