How to select the text from the first tag from each element
I have a table of Events, and I need to get the event name from each.
var event_names = new Array(); // Initialise to avoid errors
$('td.event_name a', '#the-list').each(function(){
console.log($(this).text());
event_names.push($(this).text());
});
However, this fails because there is more than one <a> tag within the
td.event_name, and I only need the first.
I've tried this also, but I'm getting the error $(this).$... is not a
function.
var event_names = new Array(); // Initialise to avoid errors
$('td.event_name', '#the-list').each(function(){
console.log($(this).$('a:first').text());
event_names.push($(this).$('a:first').text());
});
Does anybody know how I could get round this?
Here is some source, for just one of the <td> elements. I cannot see any
obvioius selectors to work off of in this code (and I cannot change it).
<td class="event_name column-event_name">
<label><strong><a title="Edit this event"
href="admin.php?page=dd-options-edit-event&event=126"
class="edit">
Test Event
</a></strong></label>
<img style="display: none; margin-left: 10px;"
src="http://test.dynedrewett.com/wp-admin/images/wpspin_light.gif"
alt="" class="waiting">
<div class="row-actions">
<span class="edit"><a title="Edit this event"
href="admin.php?page=dd-options-edit-event&event=126"
class="edit">Edit</a> | </span>
<span class="inline hide-if-no-js"><a title="Quick edit this
event" href="#" class="editinline">Quick Edit</a> | </span>
<span class="copy"><a title="Copy this event" href="#"
class="single-copy">Copy</a> | </span>
<span class="delete"><a title="Delete this event" href="#"
class="single-delete">Delete</a> | </span>
<span class="open"><a target="_blank" title="Close this event"
href="#" class="single-switch-state">Close</a> | </span>
<span class="view"><a target="_blank" title="View this event"
href="http://test.dynedrewett.com/events/?e=126"
class="single-view">View</a> | </span>
<span class="invitations"><a title="Manage invitations to this
event"
href="http://test.dynedrewett.com/wp-admin/admin.php?page=dd-options-event-invitations&event=126"
class="single-view">Invitations</a></span>
</div>
</td>
No comments:
Post a Comment