How to Add a quertystring to a link using jquery
You've got nothing to hook onto for that second attr() as you're not storing the result of the jQuery call in a variable.

I'd advise using a loop instead:

$('a[href^="/mypath/"]').each(function(index, element) {
  var newAttr = $(element).attr('href') + '?parent=' + Drupal.settings.nodeinfo.nid;
  $(element).attr('href', newAttr);
});


That will catch any link on the page that matches the path selector.