0

Am trying getting the value of variable GET... this is my code:

$('.x').append("<li><a class='smsContact' href='#SMS2?telefone=testeValue></a>");
user2647038
  • 163
  • 6
  • You are trying to get a value from the querystring with javascript? This looks like it could help you [Get URL parameter with JavaScript or jQuery](http://stackoverflow.com/questions/1403888/get-url-parameter-with-javascript-or-jquery) – user1477388 Aug 28 '13 at 17:19
  • sorry guys ... I edited ... the correct code its now above – user2647038 Aug 28 '13 at 17:24
  • try this http://jquerybyexample.blogspot.com/2012/06/get-url-parameters-using-jquery.html – SAFEER N Aug 28 '13 at 17:26

1 Answers1

1

I'm not exactly sure what you mean by "variable GET"? If you are referring to the a element's href attribute, and specifically the parts that would be available on a PHP GET command at the other end...

Using jQuery it would look like this:

Working jsFiddle here

$('.smsContact').click(function() {
    xx = $(this).attr('href'); 
    alert('href is:  ' + xx);
    justval = xx.split('=');
    yy = justval[1];
    alert('Just the value is:  ' + yy);
});
cssyphus
  • 37,875
  • 18
  • 96
  • 111
  • 2
    Terrible variable names there. Can't you be bothered to teach starters how to properly write clean and self-documenting code? You're also polluting the global variable scope this way, by the way. – BalusC Aug 28 '13 at 17:35
  • Very good point. This is totally throw-away code, intended only for example, so I won't update variable names here. However, in future I will think twice and thrice. Thank you for making this point. +1 – cssyphus Aug 28 '13 at 17:46