Napoleon Wai Lun Wong Napoleon Wai Lun Wong - 3 months ago 15
jQuery Question

Jquery cant get dynamic data

I am a noob to using jQuery. I have a problem with an error


Uncaught SyntaxError: Unexpected token


I am using version 1.9.0 of jQuery. I am creating a dynamic number of record, each record would create a
tr
in a table, also I want to add some dynamic coding into the textbox

Part of my Html markup:

<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 code:

$('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() <--- i cant getting the DATA

Answer

Error #2 : (bracket is missing before .each starts)

$('tr[id^="row_"]'.each(function(){
     var rowid = parsInt(this.id.replace("row_",""));
     console.lof("id:"+ rowid);
            var ??? = new jscolor.color(document.getElementById('???'), {})
 });  

it should be

$('tr[id^="row_"]').each(function(){
     var rowid = parseInt(this.id.replace("row_",""));
     console.log("id:"+ rowid);
            var ??? = new jscolor.color(document.getElementById('???'), {})
 }); 
Comments