0

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?

Sirwan Afifi
  • 10,366
  • 13
  • 56
  • 108

1 Answers1

1

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.

David Hedlund
  • 125,403
  • 30
  • 199
  • 217