I am experimenting with a new platform of forums and a problem has arisen to me: I have tried to load, by means of load
, a section of the forum to extract its id and place it on the current page. What happens is that, for some reason, when looking for the element (in the section to extract the id) you simply can not find it.
I have read there that I should use on
, but no matter how hard I try, I do not finish configuring it as it should, therefore I come here to ask for help.
This is the base code, without the uses of the on
, which always assigns undefined for the reason that I have already explained.
var topfor = $('#ST .activeuserstrip:nth-last-child(2) strong a').attr('href');
$('#actualfor').load(topfor + ' .forum-header');
var actfor = $('.forum-header').attr('id');
$('#ST .maintitle')[0].setAttribute('id', actfor);
And this is the simplified HTML:
<body id="ST" class="user-1 mod-1 admin-1">
<div id="forum-hidden">
<div id="actualfor">
<div id="forum-1" class="forum-header">
<div class="forum-cover">
<div class="forum-name">
A Test Forum
</div>
</div>
</div>
</div>
</div>
<div id="forum-body">
<div id="forum-center">
<div id="wrapper">
<div id="innerwrapper">
<div class="tableborder">
<div class="maintitle" id="undefined">
<span class="topic-title">Prueba</span>, Prueba</div>
</div>
</div>
<div class="activeuserstrip" align="center">
<!--SOCIAL_BOOKMARKS--> « <a href="URL 1">Next Oldest</a> | <strong><a href="URL 2">A Test Forum</a></strong> | <a href="URL 3">Next Newest</a> »
</div>
</div>
</div>
</div>
</div>
</div>