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/)
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With