在jQuery的你可以這樣做:而不是在DOM上的變量上使用jQuery?
$("a[href$='.img']").each(function(index) {
alert($(this).attr('href'));
}
我想寫一個jQuery函數從一個網站抓取的x水平,並收集所有的HREF爲GIF圖像。
所以,當我使用的得到函數來獲取另一個頁面,
$.get(href, function(data) {
});
我希望能夠像做
data.$("a[href$='.img']").each(function(index) {
});
這可能嗎?
......更新中...
多虧了答案,我能解決這個問題。
function FetchPage(href) {
$.ajax({
url: href,
async: false,
cache: false,
success: function(html){
$("#__tmp__").append("<page><name>" + href + "</name><content>" + html + "</content></page>");
}
});
}
見this zip fil E對於一個例子,如何使用它。