0

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

$('.x').append("<li><a class='smsContact' href='#SMS2?telefone=testeValue></a>");
3

1 Answer 1

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);
});
Sign up to request clarification or add additional context in comments.

2 Comments

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.
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.