System32
Active Coder
So, I have this code:
The HTML I get is:
All I need is to extract first link href and ignore everything else. And first href value is: /t2-solvednbeka-nova-tema#3
How can I do that? :/
JavaScript:
$(document).ready(function() {
$(".share_post").click(function(event) {
var post = $(this).parent().parent().parent().parent().html();
alert(post); // Shows html
event.preventDefault();
});
});
Code:
<div id="3" class="post-header"><h2><i class="material-icons">description</i><img src="https://2img.net/i/empty.gif" alt="[solved]nbeka nova tema Empty" loading="lazy"><span class="post-heading-wrap"><a href="/t2-solvednbeka-nova-tema#3">[solved]nbeka nova tema</a><span class="post-date">Wed 16 Nov 2022 - 10:40</span></span></h2><div class="mobile-hide post-buttons"><ul><li class="btn-quote-multi"><span title="Select/Unselect multi-quote" id="post_mq2_3" onclick="togglePostMultiQuote(this);"><i class="material-icons">format_quote</i><i class="material-icons">add</i></span></li><li class="btn-quote"><a href="/post?p=3&mode=quote" title="Reply with quote"><i class="material-icons">format_quote</i></a></li><li class="btn-edit"><a href="/post?p=3&mode=editpost" title="Edit/Delete this post"><i class="material-icons">edit</i></a></li><li class="btn-delete"><a href="/post?p=3&tid=43df79a271e9e3ff7a4a3af2f9b1a8d1&mode=delete" title="Delete this post"><i class="material-icons">delete</i></a></li><li class="btn-ip"><a href="/modcp?mode=ip&p=3&t=2&tid=43df79a271e9e3ff7a4a3af2f9b1a8d1" title="View IP address of poster"><i class="material-icons">info</i></a></li><li class="share_post"><i class="material-icons">share</i></li> </ul></div><div class="mobile-show dropdown post-buttons-mobile"><i class="material-icons">more_horiz</i><ul class="dropdown-box"><li class="btn-quote-multi"><span title="Select/Unselect multi-quote" id="post_mq2_3" onclick="togglePostMultiQuote(this);"><i class="material-icons">format_quote</i><i class="material-icons">add</i></span></li><li class="btn-quote"><a href="/post?p=3&mode=quote" title="Reply with quote"><i class="material-icons">format_quote</i></a></li><li class="btn-edit"><a href="/post?p=3&mode=editpost" title="Edit/Delete this post"><i class="material-icons">edit</i></a></li><li class="btn-delete"><a href="/post?p=3&tid=43df79a271e9e3ff7a4a3af2f9b1a8d1&mode=delete" title="Delete this post"><i class="material-icons">delete</i></a></li><li class="btn-ip"><a href="/modcp?mode=ip&p=3&t=2&tid=43df79a271e9e3ff7a4a3af2f9b1a8d1" title="View IP address of poster"><i class="material-icons">info</i></a></li></ul></div></div><div class="post-body"><div class="post"><div class="post-content"> <div class="personal-vote"> <a href="" class="vote-up"><i class="material-icons">keyboard_arrow_up</i></a><h4>0</h4><a href="" class="vote-down"><i class="material-icons">keyboard_arrow_downp</i></a> </div><!--
REPUTATION SYSTEM --><div>random tekst<br><br>dfgdfg</div><br><br>Last edited by Admin on Mon 28 Nov 2022 - 20:25; edited 2 times in total (Reason for editing : test)</div><div class="post-footer likes-active vote-active"><div class="fa_like_div"><button class="rep-button fa_liked" data-href="/vote_like?cvf%5B0%5D=358013163b670b431c6e06e945524d63&cvf%5B1%5D=e4da8661604a937ccab27790ccf2baf3&l_vote=3&like_val=3" data-href-rm="/vote_like?cvf%5B0%5D=d563efcabf02b6c7f382e68685a634ac&cvf%5B1%5D=fefd1e2b3bbcafafd96e82becb3a4a6d&l_vote=3&like_val=5"><span class="rep-cat"><i class="material-icons">thumb_up</i><span class="rep-nb">2</span></span><span>Like</span></button><button class="rep-button fa_dislike" data-href="/vote_like?cvf%5B0%5D=fd9223540c0ace38e28fbf8f4968cedc&cvf%5B1%5D=81a5dad70fd4bc4d5026c514884f2a1c&l_vote=3&like_val=4" data-href-rm="/vote_like?cvf%5B0%5D=d563efcabf02b6c7f382e68685a634ac&cvf%5B1%5D=fefd1e2b3bbcafafd96e82becb3a4a6d&l_vote=3&like_val=5"><span class="rep-cat"><i class="material-icons">thumb_down</i><span class="rep-nb" style="display:none;"></span></span><span>Sad</span></button><p class="fa_like_list"><a href="/u1">Admin</a> and <a href="/u2">testacc</a> like this post</p><p class="fa_dislike_list" style="display: none;"></p></div><div class="vote"><div class="vote-bar" title="Message reputation : 100% (2 votes)"><div class="vote-bar-desc">Message reputation : 100% (2 votes)</div><div class="vote-bars"><div class="vote-bar-plus" style="width:50px;"></div></div></div></div></div></div><aside class="post-aside"><div class="post-author-status"></div><div class="post-author"><span class="post-author-name"><a href="/u1"><span style="color:#000099"><strong>Admin</strong></span></a></span><span class="post-author-title">Admin<br></span></div><div class="post-author-avatar"><div class="avatar-big"><a href="/u1"><img loading="lazy" src="https://2img.net/i/fa/modernbb/pp-blank-thumb.png" alt="avatar"></a></div></div><div class="dd_award right box-body" style="display: none;"></div><div class="award_more box-body"></div><br><dl class="post-author-details"><dt><span class="label"><span style="color:#263238;"><img src="https://i.ibb.co/StLYbWS/7665584-25x25.png" alt=" Title"></span></span></dt><dd>Dreamer</dd><dt><span class="label"><span style="color:#263238;">Posts</span> : </span></dt><dd>14</dd><dt><span class="label"><span style="color:#263238;">Join date</span> : </span></dt><dd>2022-11-12</dd></dl><div class="post-author-rpg"></div><div class="post-author-contact dropdown"><i class="material-icons">keyboard_arrow_down</i><div class="dropdown-box"><a href="/u1" class="profile-icon" title="View user profile"><img src="https://2img.net/i/fa/awesomebb/icon_user_profile.png" class="i_icon_profile " alt="View user profile" loading="lazy"></a><a href="/privmsg?mode=post&u=1" class="profile-icon" title="Send private message"><img src="https://2img.net/i/fa/awesomebb/icon_contact_pm.png" class="i_icon_pm " alt="Send private message" loading="lazy"></a><a href="/profile?mode=email&u=1"><img src="https://2img.net/i/fa/awesomebb/icon_contact_email.png" alt="Send e-mail" title="Send e-mail" loading="lazy"></a><a href="https://testaca.forumotion.me" title="Visit poster's website" target="_blank" rel="nofollow"><img src="https://2img.net/i/fa/awesomebb/icon_contact_www.png" alt="https://testaca.forumotion.me"></a></div></div></aside></div>
All I need is to extract first link href and ignore everything else. And first href value is: /t2-solvednbeka-nova-tema#3
How can I do that? :/