[javascript] open new tab(window) by clicking a link in jquery

I have a web app that displays rows with go and delete buttons.

If a user clicks go, it should open new tab/window with url built from the row's data.

how can I do this in jquery? What I'm doing is :

$('.go').click( function () {
   var wid = {{ wid|tojson|safe }};
   var sid = $(this).prop('id');
   url = $script_root + '/' + wid + '/' + sid;

   // go to url
});

some update:

What I'm really tring to accomplish is dynamically update href of an <a> element.

<a id="foo" href="#">foo</a>
<script type="text/javascript>
$('#foo').click( function() {
  $(this).prop('href', 'http://www.google.com/');
});
</script>

which doesn't work (fiddle :http://jsfiddle.net/6eLjA/)

This question is related to javascript jquery

The answer is


Try this:

window.open(url, '_blank');

This will open in new tab (if your code is synchronous and in this case it is. in other case it would open a window)