简体   繁体   中英

Click a link having same class among other classes and same link name among other link name

I want to click on this link automatically. the href and data-id is generated randomly on website. and also have other links on website which have same class and same link name.

I want to click the first link among the other similar link on the webpage.

 <a class="btn btn-success btn-mini bid-now ProjectTable-control" href="www.example.com/random" data-id="13033246">Bid Now</a>

Here are some more code for better understanding:

<td class=" ProjectTable-cell ProjectTable-priceColumn price-col"><span class="average-bid">$2400</span><div class="ProjectTable-controls">
    <a class="btn btn-success btn-mini bid-now ProjectTable-control" href="/projects/view_new.php?id=13033253#placebid" data-id="13033253">
        Bid Now
    </a>





        <a class="btn btn-primary btn-mini repost ProjectTable-control" data-ttref="PostProject_ProjectListingLoggedIn" data-type="p" data-qts="PostProject" data-id="13033253" href="https://www.example.com/buyers/repost.php?id=13033253">
            Post a project like this
        </a>

document.getElementsByClassName('bid-now ProjectTable-control')[0].click() 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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