Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  
</body>
</html>
 
$(function() {
  var url = 'http://jsbin.com/ocoteg/1';
  $.get(url).complete(function(xhr) {    
    var text = xhr.responseText;       
    var dom = $(text);
    
    console.log(dom);
    
    // Now I want to replace all links with a span and get the modified html text back
    
    dom.filter('a').each(function() {
      var el = $(this);
      var html = el.html();
      var span = $('<span/>').html(html);
      el.replaceWith(span);
    });
    
    console.log(dom);
    
    // So the links weren't replaced
    
    // How to get the modified string back
    
  });
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers