简体   繁体   English

获取attr表格

[英]Get attr form <a href>

ive got a problem with getting attr from <a href> . 我从<a href>获取attr遇到了问题。

Got something likte this 有喜欢的东西

<a href="#callback" realurl="callback.aspx">Callback</a>

And jQuery 和jQuery

$('#callback').bind('pageAnimationEnd', function (e, info) {

                var realurl = $(this).attr('realurl');

                if (!$(this).data('loaded')) {
                    $(this).append($('<table border=0 width="100%" height="100%"><tr width="100%" height="100%"><td>Wczytuję...</td></tr></table>').
                        load(realurl, function () {
                            $(this).parent().data('loaded', true);
                            $('#ParentTest').html("test");
                        }));
                }
            });

And im getting all the time undefined from $(this).attr('realurl'). 我从$(this).attr('realurl')获取所有时间未定义。

This does not work the way you intend. 这不符合您的预期。

$('#callback')

finds the elements having id="callback" . 查找具有id="callback"的元素。 So if your HTML would be like: 因此,如果您的HTML是这样的:

<a id="callback" href="#callback" realurl="callback.aspx">Callback</a>

it would work. 它会工作。 Alternatively, you can leave the html as is and write: 或者,您可以保留html并编写:

$("a[@href='#callback']")

instead. 代替。 This should get all a elements having the href attribute set to #callback 这应该让所有a具有元素href属性设置为#callback

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM