Locate and click something - var clicktarget, query selector









up vote
0
down vote

favorite












So I have this code:



<div class="follow">
<center>
<img src="http://img.youtube.com/vi/pXgWFgV2ayM/1.jpg" alt="how to get free robux" title="how to get free robux" class="follower" width="80" border="0"><br><b>Coins</b>: 9<br>
<a href="p.php?p=youtube&amp;vid=22704" class="followbutton">Watch Video</a>
<font style="font-size:0.8em;">[<a href="p.php?p=youtube&amp;a=skip&amp;id=22704" style="color: #999999;font-size:0.9em;">skip</a>]</font>
<span style="position:absolute;bottom:1px;right:2px;"><a href="javascript:void(0);" onclick="report_page('22704','aHR0cDovL3d3dy55b3V0dWJlLmNvbS93YXRjaD92PXBYZ1dGZ1YyYXlN','youtube');"><img src="img/report.png" alt="Report" title="Report" border="0"></a></span>
</center>




And I have this code which selects/clicks the skip button (Line 5) in the code above:



 var elparent = elements[i].parentNode;
var clicktarget = elparent.querySelector("font a");
clicktarget.click();
console.log("sleeping for 3 seconds");


Now I have this code:



<div class="media" id="427731">
<div class="media-left">
<a href="#">
<img class="media-object" src="//img.youtube.com/vi/YJy4f_cc-GQ/1.jpg" alt="Hubungan Langgeng">
</a>
</div>
<div class="media-body">
<h4 class="media-heading">Points: 9</h4>
<a href="p.php?p=youtube&amp;vid=427731" class="btn btn-default">Watch</a>
<a href="p.php?p=youtube&amp;a=skip&amp;id=427731" class="btn btn-danger">Skip</a>
<a href="javascript:void(0);" class="btn btn-warning" onclick="report_page('427731','Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1ZSnk0Zl9jYy1HUQ==','youtube');">Report</a>
</div>




What code would I use to select/click the Skip button (Line 10) here?



Thank you










share|improve this question

























    up vote
    0
    down vote

    favorite












    So I have this code:



    <div class="follow">
    <center>
    <img src="http://img.youtube.com/vi/pXgWFgV2ayM/1.jpg" alt="how to get free robux" title="how to get free robux" class="follower" width="80" border="0"><br><b>Coins</b>: 9<br>
    <a href="p.php?p=youtube&amp;vid=22704" class="followbutton">Watch Video</a>
    <font style="font-size:0.8em;">[<a href="p.php?p=youtube&amp;a=skip&amp;id=22704" style="color: #999999;font-size:0.9em;">skip</a>]</font>
    <span style="position:absolute;bottom:1px;right:2px;"><a href="javascript:void(0);" onclick="report_page('22704','aHR0cDovL3d3dy55b3V0dWJlLmNvbS93YXRjaD92PXBYZ1dGZ1YyYXlN','youtube');"><img src="img/report.png" alt="Report" title="Report" border="0"></a></span>
    </center>




    And I have this code which selects/clicks the skip button (Line 5) in the code above:



     var elparent = elements[i].parentNode;
    var clicktarget = elparent.querySelector("font a");
    clicktarget.click();
    console.log("sleeping for 3 seconds");


    Now I have this code:



    <div class="media" id="427731">
    <div class="media-left">
    <a href="#">
    <img class="media-object" src="//img.youtube.com/vi/YJy4f_cc-GQ/1.jpg" alt="Hubungan Langgeng">
    </a>
    </div>
    <div class="media-body">
    <h4 class="media-heading">Points: 9</h4>
    <a href="p.php?p=youtube&amp;vid=427731" class="btn btn-default">Watch</a>
    <a href="p.php?p=youtube&amp;a=skip&amp;id=427731" class="btn btn-danger">Skip</a>
    <a href="javascript:void(0);" class="btn btn-warning" onclick="report_page('427731','Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1ZSnk0Zl9jYy1HUQ==','youtube');">Report</a>
    </div>




    What code would I use to select/click the Skip button (Line 10) here?



    Thank you










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      So I have this code:



      <div class="follow">
      <center>
      <img src="http://img.youtube.com/vi/pXgWFgV2ayM/1.jpg" alt="how to get free robux" title="how to get free robux" class="follower" width="80" border="0"><br><b>Coins</b>: 9<br>
      <a href="p.php?p=youtube&amp;vid=22704" class="followbutton">Watch Video</a>
      <font style="font-size:0.8em;">[<a href="p.php?p=youtube&amp;a=skip&amp;id=22704" style="color: #999999;font-size:0.9em;">skip</a>]</font>
      <span style="position:absolute;bottom:1px;right:2px;"><a href="javascript:void(0);" onclick="report_page('22704','aHR0cDovL3d3dy55b3V0dWJlLmNvbS93YXRjaD92PXBYZ1dGZ1YyYXlN','youtube');"><img src="img/report.png" alt="Report" title="Report" border="0"></a></span>
      </center>




      And I have this code which selects/clicks the skip button (Line 5) in the code above:



       var elparent = elements[i].parentNode;
      var clicktarget = elparent.querySelector("font a");
      clicktarget.click();
      console.log("sleeping for 3 seconds");


      Now I have this code:



      <div class="media" id="427731">
      <div class="media-left">
      <a href="#">
      <img class="media-object" src="//img.youtube.com/vi/YJy4f_cc-GQ/1.jpg" alt="Hubungan Langgeng">
      </a>
      </div>
      <div class="media-body">
      <h4 class="media-heading">Points: 9</h4>
      <a href="p.php?p=youtube&amp;vid=427731" class="btn btn-default">Watch</a>
      <a href="p.php?p=youtube&amp;a=skip&amp;id=427731" class="btn btn-danger">Skip</a>
      <a href="javascript:void(0);" class="btn btn-warning" onclick="report_page('427731','Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1ZSnk0Zl9jYy1HUQ==','youtube');">Report</a>
      </div>




      What code would I use to select/click the Skip button (Line 10) here?



      Thank you










      share|improve this question













      So I have this code:



      <div class="follow">
      <center>
      <img src="http://img.youtube.com/vi/pXgWFgV2ayM/1.jpg" alt="how to get free robux" title="how to get free robux" class="follower" width="80" border="0"><br><b>Coins</b>: 9<br>
      <a href="p.php?p=youtube&amp;vid=22704" class="followbutton">Watch Video</a>
      <font style="font-size:0.8em;">[<a href="p.php?p=youtube&amp;a=skip&amp;id=22704" style="color: #999999;font-size:0.9em;">skip</a>]</font>
      <span style="position:absolute;bottom:1px;right:2px;"><a href="javascript:void(0);" onclick="report_page('22704','aHR0cDovL3d3dy55b3V0dWJlLmNvbS93YXRjaD92PXBYZ1dGZ1YyYXlN','youtube');"><img src="img/report.png" alt="Report" title="Report" border="0"></a></span>
      </center>




      And I have this code which selects/clicks the skip button (Line 5) in the code above:



       var elparent = elements[i].parentNode;
      var clicktarget = elparent.querySelector("font a");
      clicktarget.click();
      console.log("sleeping for 3 seconds");


      Now I have this code:



      <div class="media" id="427731">
      <div class="media-left">
      <a href="#">
      <img class="media-object" src="//img.youtube.com/vi/YJy4f_cc-GQ/1.jpg" alt="Hubungan Langgeng">
      </a>
      </div>
      <div class="media-body">
      <h4 class="media-heading">Points: 9</h4>
      <a href="p.php?p=youtube&amp;vid=427731" class="btn btn-default">Watch</a>
      <a href="p.php?p=youtube&amp;a=skip&amp;id=427731" class="btn btn-danger">Skip</a>
      <a href="javascript:void(0);" class="btn btn-warning" onclick="report_page('427731','Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1ZSnk0Zl9jYy1HUQ==','youtube');">Report</a>
      </div>




      What code would I use to select/click the Skip button (Line 10) here?



      Thank you







      jquery var






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 11 at 19:49









      Overloard

      98111




      98111



























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53252560%2flocate-and-click-something-var-clicktarget-query-selector%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53252560%2flocate-and-click-something-var-clicktarget-query-selector%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Barbados

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3