如果你的remove掉的话 页面上已经没有了 得自己重新创建 本着你要想继续用这个标签建议不要remove掉hide隐藏掉就可以了
解决方案 »
- 请教一个关于iframe的问题
- jquery图片预览例子的疑问
- 写了一个简单的javascript 不执行,麻烦大家看下
- 刚学js,有个关于frame操作得问题?
- jquery cookie 设置 疑问
- 那里有象createtextrange()函数的说明?
- 如何打开一个新的窗口,同时让这个新窗口的关闭按纽不好用呀?
- 请教一个页面刷新的问题
- javascript的confirm对话框,点击“确定”后,触发form中的一个按钮(submit)的onclick事件
- 急急, 有一個總框架,它抱括几個子框架, 我想在任一個子框架中, 放一個關閉按鈕...
- java表格打印问题
- 求教jquery 鼠标滚动到底后,连续执行函数问题
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".div_btn").click(function(){
$(this).(".div_c").show();
$(this).hide();
})
$(".div_c").click(function(){
$(".div_btn").show();
$(this).hide();
})
});
</script>
<style type="text/css">
*{
margin:0;
padding:0;
}
.div{
width:300px;
height:200px;
border:1px solid #DCDCDC;
float:left;
position:relative;
}
.div_btn{
width:70px;
height:30px;
background:#00BCF3;
float:right;
margin:150px 20px 0 0;
line-height:30px;
text-align:center;
color:#FFF;
}
.div_c{
width:70px;
height:30px;
background:#00BCF3;
position:absolute;
top:10px;
right:10px;
display:none;
}
</style>
</head><body>
<div class="div">
<a href="javascript:;" class="div_c">点击</a>
<a href="javascript:;" class="div_btn">点击</a>
</div>
<div class="div">
<a href="javascript:;" class="div_c">点击</a>
<a href="javascript:;" class="div_btn">点击</a>
</div>
<div class="div">
<a href="javascript:;" class="div_c">点击</a>
<a href="javascript:;" class="div_btn">点击</a>
</div></body>
</html>
请问下 我现在都改成隐藏的了
这些问题应该怎么解决啊 当我点击".div_btn"的时候 创建了".div_c" 当点击创建".div_c" 还原".div_btn"
还有就是在点击其他的".div_btn"的时候 已经创建了的".div_c" 也要还原回去请问下 应该怎么做啊
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var cj = "<a class='div_c'></a>";
$(".div_btn").each(function() {
var o = $(this);
var p = o.closest('div'); p.click(function(e) {
var t = e.target;
var flag = false;
var newb;
if (t.className.indexOf('div_btn') !== -1) {
if (!flag) {
newb = $(cj);
newb.appendTo(p);
o.hide();
flag = true;
} else {
newb.show();
o.hide();
}
} else if (t.className.indexOf('div_c') !== -1) {
$(t).hide();
o.show();
} })
}) });
</script>
<style type="text/css">
* {
margin: 0;
padding: 0;
}.div {
width: 300px;
height: 200px;
border: 1px solid #DCDCDC;
float: left;
position: relative;
}.div_btn {
width: 70px;
height: 30px;
background: #00BCF3;
float: right;
margin: 150px 20px 0 0;
line-height: 30px;
text-align: center;
color: #FFF;
}.div_c {
width: 70px;
height: 30px;
background: #00BCF3;
position: absolute;
top: 10px;
right: 10px;
}
</style>
</head><body>
<div class="div"> <a href="javascript:;" class="div_btn">点击</a>
</div>
<div class="div"> <a href="javascript:;" class="div_btn">点击</a>
</div>
<div class="div"> <a href="javascript:;" class="div_btn">点击</a>
</div></body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){ var cj='<a onclick="javascript:hide(this);" class="div_c" href="#">点击</a>';
$(".div_btn").each(function(){
$(this).click(function(){
$(this).closest('div').append(cj);
$(this).closest('div').siblings('.div').find(".div_c:visible").remove();
$(this).closest('div').siblings('.div').find(".div_btn:hidden").show();
$(this).hide();
})
})
});
function hide(obj){
$(obj).siblings('.div_btn').show();
$(obj).remove();
}
</script>
<style type="text/css">
*{
margin:0;
padding:0;
}
.div{
width:300px;
height:200px;
border:1px solid #DCDCDC;
float:left;
position:relative;
}
.div_btn{
width:70px;
height:30px;
background:#00BCF3;
float:right;
margin:150px 20px 0 0;
line-height:30px;
text-align:center;
color:#FFF;
}
.div_c{
width:70px;
height:30px;
background:#00BCF3;
position:absolute;
top:10px;
right:10px;
}
</style>
</head><body>
<div class="div"> <a href="javascript:;" class="div_btn">点击</a>
</div>
<div class="div">
<a href="javascript:;" class="div_btn">点击</a>
</div>
<div class="div">
<a href="javascript:;" class="div_btn">点击</a>
</div></body>
</html>
$(document).ready(function() {
var cj = "<a class='div_c'></a>";
$(".div_btn").each(function() {
var o = $(this);
var p = o.closest('div');
var flag = false;
var newb;
p.click(function(e) {
var t = e.target;
if (t.className.indexOf('div_btn') !== -1) {
if (!flag) {
newb = $(cj);
newb.appendTo(p);
o.hide();
flag = true;
} else {
newb.show();
o.hide();
}
} else if (t.className.indexOf('div_c') !== -1) {
$(t).hide();
o.show();
}
})
})
});