[英]Jquery : Remove created element if CLICKED button value is xxx
我在"Information button"
上"Information button"
创建一个div(包含内容),然后使用$("#").toggle();
将值"Information button"
更改为“返回” $("#").toggle();
现在我之前创建的div并没有被删除,尽管我有这个
if ($(this).val() == 'Go Back') {$('#msg').remove();}
这是我的代码;
$("#InformationButton").one('click',function () {
$('<div>stackoverflow -- dynamically created content</div> ', {
id: 'Interface',
text: ''}).appendTo('#main-section');
$("#Interface").toggle("slow", "linear");
})
$('.InformationButton').click(function () {
$(".PageBody").fadeToggle("fast", "linear");
$(this).val($(this).val() == 'Information button' ? 'Go Back' : 'Information button');
$("#Interface").toggle();
});
$('.InformationButton').click(function () {
if ($(this).val() == 'Go Back') {
$('#Interface').remove();
}
});
我需要删除#Interface
如果上的信息按钮和值id用户点击==“返回”,并显示.PageBody。
在$('.ImpToExcel').click(function () {
这是指向类.ImpToExcel
被单击元素。
您需要保存this
的引用
$("#InformationButton").one('click',function () {
$self = $(this);
//rest of the code
$('.ImpToExcel').click(function () {
//rest of the code
$self.val($self.val() == 'Information button' ? 'Go Back' : 'Information button');
//rest of the code
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.