How get variable GET with jquery and HTML

2019-09-12 20:15发布

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

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

1条回答
劳资没心,怎么记你
2楼-- · 2019-09-12 20:34

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);
});
查看更多
登录 后发表回答