我在 targetTD [6]的行window.name = "NG_DEFER_BOOTSTRAP!";
var myApp = angular.module('myApp', []);
myApp.component('main', {
template: '<h1>Initially nothing to bind :(</h1>'
});
angular.element(document).ready(function() {
angular.bootstrap(document, ['myApp']);
// Customizing comes here in following format
var json = [{
name: 'main',
obj: {
controller: function() {
this.goof = 'Yo!';
},
template: '<span>{{ $ctrl.goof }}</span>'
}
}];
// Scary looking override logic !!1
myApp._invokeQueue.forEach(function(current) {
var obj = current[2];
var name = obj[0];
var replacement = _.findWhere(json, { name: name });
if (replacement) {
for (var key in replacement.obj) {
obj[1][key] = replacement.obj[key];
}
}
current = obj;
});
angular.resumeBootstrap();
});
上收到错误.find不是函数。 (在'targetTD [6] .find('textarea')','targetTD [6] .find'未定义)
targetTD[6].find('textarea').text()
我正在尝试在 $(document).ready(function () {
$(document.body).on('click','.edit',function () {// use button class ince ID has to be unique per button
var targetTD;
if( $(this).find('i').hasClass('glyphicon-edit'))
{
targetTD = $(this).parents('tr').find('td'); // gives all TDs of current row
if (targetTD[6].firstChild.children.length) // the value cell is what we want
{
// targetTD[6].firstChild.children.item().setAttribute('readonly','false');
alert(targetTD[6].find('textarea').text());
}
内找到一个文本区域。如何删除<td><div> <textarea readonly> some text </textarea><div><td>
属性?为什么我不能使用find?
答案 0 :(得分:0)
尝试替换:
targetTD[6].find('textarea').text();
使用:
$(targetTD[6]).find('textarea').text();
因为targetTD是一个没有包装元素的数组。此外,要删除readonly属性使用:
$(targetTD[6]).attr("readonly", false);
答案 1 :(得分:-1)
targetTD[6]
是本机JavaScript节点。您需要将其包装在jQuery选择器$()
像这样:$(targetTD[6]).find