My Code は、文字列内の 2 つの時間(つまり、13:01-14:03)の時間差を取得するために TD タグのタイトルを取得し、新しいタイトル (プロパティ) のように表示します。これは、要素のみ、複数ある場合は失敗します。
この場合、どうすればうまくいくでしょうか??
<table>
<thead>
<th>First</th>
<th>Second</th>
<th>Third</th>
<th>Ok</th>
</thead>
<tr>
<td>1</td>
<td>CCBB</td>
<td class='huifa' id='calc' title='02-01-2013 13:01-14:03'>231</td>
<td class='huifa' id='calc' title='02-01-2013 13:01-13:53'>1</td>
</tr>
<tr>
<td>2</td>
<td>CCBB</td>
<td>342</td>
<td>0</td>
</tr>
</table>
JS コード
<script>
element = document.getElementById('calc');
v = element.title
v = v.slice(11)
v = v.split('-')
totalTime = delTime(v[1],v[0]);
element.title = 'Duracion: '+totalTime
</script>
私の作業コードはここにあります: http://jsfiddle.net/cespinoza/tg86a/55/
ありがとう。