开发者

Get link value in html document with jQuery?

Let's say I have a link in a table like:

    <td class="ms-vb" width="100%">
<a onfocus="OnLink(this)" href="/Lists/Business%20Divisions/DispForm.aspx?ID=2" onclick="GoToLink(this);return false;" target="_self">Train<img src="/_layouts/images/blank.gif" class="ms-hidden" alt="" width="1" border="0" height="1">
</a></td>

How can I get the value Train with jQuery?

Thanks in advance.

edit: I currently get the querystring value from every link and push them into an array with the following code:

$("table").each(function(index, value) {
    $(this).addClass("table" + index);
});


var hrefs = new Array();
$('.table449').children().children().each(function(){
var link = ($(this).find('a').attr('href'));
var startIndex = link.indexOf(",'");
var endIndex = link.indexOf("');");
if ( startIndex >= 0 && endIndex >= 0 ) {
    var linkID = link.substring(开发者_开发问答 startIndex+2, endIndex );
  hrefs.push(linkID);
}
alert(hrefs);
});

What I want to do is to store the values like Train in another array.


Hard to tell with such a small snippet. In the provided snippet either of these would work:

$("td a").text();

$(".ms-vb a").text();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜