views:

92

answers:

1

Hi, ive got a problem with getting attr from <a href>.

Got something likte this

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

And 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').

+8  A: 

This does not work the way you intend.

$('#callback')

finds the elements having id="callback". So if your HTML would be like:

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

it would work. Alternatively, you can leave the html as is and write:

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

instead. This should get all a elements having the href attribute set to #callback

Roland Bouman
typo: s/""#callback"/"callback"/
Boldewyn
mm? Boldewyn, which occurrence is that? I think all #callback should like that? TIA, roland
Roland Bouman
@Roland: Never mind, SLaks corrected the answer.
Boldewyn