jquery无法获取动态数据
我是使用jQuery的noob。我遇到了一个错误问题jquery无法获取动态数据
Uncaught SyntaxError: Unexpected token
我使用的是jQuery 1.9.0版本。我创造纪录的动态数量,每条记录会在表中创建一个tr
,我也想加入一些动态编码到文本框中
我的HTML标记的部分:
<tbody>
<tr id="row_1">
<td class="value">
<input id="1" name="collections[appearance][headersubcolor][entity_id1][name]" value="0" class="Root Catalog input-text" type="text">
<p class="note">
<span>Click inside to change a color of each Category</span>
</p>
</td>
<td class="scope-label">
</td>
<td class="">
</td>
</tr>
<tr id="row_2">
<td class="label">
<td class="value">
<input id="2" name="collections[appearance][headersubcolor][entity_id2][name]" value="0" class="Default Category input-text" type="text">....
jQuery代码:
$('tr[id^="row_"]'.each(function(){
var rowid = parsInt(this.id.replace("row_",""));
console.lof("id:"+ rowid);
var ??? = new jscolor.color(document.getElementById('???'), {})
});
$( 'TR [ID^= “行_”]'。每个(函数()< ---我不能获取数据
错误#2:(支架。每个之前缺少开始)
$('tr[id^="row_"]'.each(function(){
var rowid = parsInt(this.id.replace("row_",""));
console.lof("id:"+ rowid);
var ??? = new jscolor.color(document.getElementById('???'), {})
});
它应该是
$('tr[id^="row_"]').each(function(){
var rowid = parseInt(this.id.replace("row_",""));
console.log("id:"+ rowid);
var ??? = new jscolor.color(document.getElementById('???'), {})
});
错误#1:
var rowid = parsInt(this.id.replace("row_",""));
应该parseInt(string, radix)
,如: -
var rowid = parseInt(this.id.replace("row_",""), 10);
___^___
错误#2:
console.lof("id:"+ rowid);
它应该是: -
console.log("id:"+ rowid);
___^___
错误#3:
$('tr[id^="row_"]'.each(function(){
它应该是: -
$('tr[id^="row_"]').each(function(){
___^___
他也在'.each'之前缺少右括号 – Steve
对,对,充满简单的错误:) –
你有几个输入错误在那里,
parseInt and console.log
//$('tr[id^="row_"]' - needs a)
//like this:
$('tr[id^="row_"]');
//运行控制台中的以下内容:
$('tr[id^="row_"]');
如果doesent回报元素,您的选择(CSS)是错误的。
我不确定你要在这里做什么,但立即我看到一些语法错误...在选择器上缺少结束标记应该是$('tr [id^=“row_”]') .each(...和console.lof而不是console.log,var ???也是无效的(或者你问我们你应该给你的变量命名?) –