I want to select all links (I want to save href
of a
tags into file) then save into a text file :
$('a.show').each(
function(){
//save into text file
// file=$(this).attr('href'); // something like this
}
);
How can I do that?
I want to select all links (I want to save href
of a
tags into file) then save into a text file :
$('a.show').each(
function(){
//save into text file
// file=$(this).attr('href'); // something like this
}
);
How can I do that?
You can get a list of all href
values on a page like so:
var urls = $('a').map(function() { return this.href; }).toArray().join(',');
However, JavaScript in a browser normally doesn't have permission to access the file system. You may post the values to a server, and perform the write operation from there.