閉じるボタンを使用して、さまざまなリンクでdivを切り替えています。残念ながら、閉じるボタンは絶対位置にリンクされているため、div自体に接続されていないため、本来の動作をしていません。私がそれをposition:relativeに置くと、新しいオープニングごとにdivに新しいボタンが追加されます。これはピーナッツに違いない、と私は知っているが、私の知識は非常に基本的なものなので、助けていただければ幸いです。ありがとうMrGreen
脚本
$(function(){
$(".action").click (function(){
var $this = $(this);
var target = $this.data('content');
$('.action').not($this).each(function(){
var $other = $(this);
var otherTarget = $other.data('content');
$(otherTarget).hide(400);
});
var cls = $('<div/>', {
'style':'left:843px;top:15px;width:12px;height:18px;cursor:pointer;padding:3px;position:absolute;border:solid gray 0px;background-color:',
'id':'cls',
'text':'x',
'title':'Close',
'click':function(){
var t=$(this);
t.parent().hide(400, function(){
t.remove();
});
}
});
$(target).prepend(cls).show({height: "toggle"},400);
});
});