我有一個簡單的HTML表是這樣的:我可以在單個警報中提醒()所有javascript數組元素嗎?
<table>
<thead>
<tr>
<th id="lname"><span title="sort this column">Last Name</span>
</th>
<th id="fname"><span title="sort this column">First Name</span>
</th>
<th id="scanned"><span title="sort this column">Scanned In</span>
</th>
<th id="department"><span title="sort this column">Department</span>
</th>
<th id="category"><span title="sort this column">Category</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="blah">LNAME1</td>
<td>FNAME1</td>
<td>06/25/13 12:48 PM</td>
<td>Internal Medicine</td>
<td>Fellow</td>
</tr>
<tr>
<td class="blah">LNAME1</td>
<td>FNAME1</td>
<td>06/25/13 12:48 PM</td>
<td>Internal Medicine</td>
<td>Fellow</td>
</tr>
<tr>
<td class="blah">LNAME1</td>
<td>FNAME1</td>
<td>06/26/13 07:29 AM</td>
<td>Internal Medicine</td>
<td>Faculty</td>
</tr>
<tr>
<td class="blah">LNAME1</td>
<td>FNAME1</td>
<td>06/26/13 07:21 AM</td>
<td>Internal Medicine</td>
<td>Faculty</td>
</tr>
</tbody>
</table>
而且一個JavaScript/jQuery代碼會是這樣的:
var count = 0;
var scannedArr = new Array();
$('table tr').each(function(){
var times = $(this).find('.blah').text();
scannedArr[count] = times;
count++;
});
我試圖在這做的JavaScript函數包括數組的元素都在一個單獨的alert()中。我可以這樣做嗎?有沒有更簡單的方法去解決它?
在此先感謝!
說,alert(scannedArr) – dandavis
'alert(scannedArr)'不適合你嗎? – Bergi