我是 Jquery 的新手,请帮助我。 目前我在标题中插入星号类,但我想在插入之前再检查一个条件,请帮助我如何检查。 目前它继续在网格中插入每个编辑按钮单击。但是我只想插入一次,如果它已经存在于标题中那么我不应该再次插入 mycode,我正在使用 Kendo Edit Grid-
edit: function (e) {
var grid = this; e.container.find('td').each(function (_, x)
{
var cell = $(x);
var input = cell.find('input[name]');
if (input.attr('name')) {
var headerCell = grid.thead.find('th:eq(' + cell.index() + ')');
headerCell.append($(''));
}
});
}
CSS 类名 -
.asterisk:after {
content: " *";
color: #b1001d;
}
最佳答案
我可以给你普通的 javascript 代码。因为 jquery 不再有用了。
if(typeof(element)!== 'undefined'){
//your code
//eg:
const newElement = '<h1>hello</h1>'
element.append(newElement)
}
关于jquery - 如何在使用 Jquery 插入之前检查特定的 html 元素是否已经存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55063964/