-2

I am trying to grab the value of my href in jquery how is it done'?

This is what I have done:

$('#playbackbutton').click(
      function() {
         $("#playbackdiv").load("$('a:href').val();", [], function(){
               $("#playbackdiv").dialog("open");
            }
         );
         return false;
      }

I need to get the value of the href in my a tag.

here is the html:

<a href="/record/123.wav">play</a>
user342391
  • 7,569
  • 23
  • 66
  • 88
  • similar to : http://stackoverflow.com/questions/872217/jquery-how-to-extract-value-from-href-tag witch present a good answer. – Milche Patern Jan 11 '13 at 19:20

3 Answers3

5
<a id="link" href="here.html">here</a>
<script type="text/javascript">
$(function() {
    alert($('#link').attr('href'));
});
</script>
Matt
  • 74,352
  • 26
  • 153
  • 180
flipdoubt
  • 13,897
  • 15
  • 64
  • 96
3
$("a").attr("href")
MBO
  • 30,379
  • 5
  • 50
  • 52
0

You should be able to use the attr method

Simon
  • 984
  • 1
  • 8
  • 24