0

I have the following code:

<div class="row">
    <div style="width: 10vw; display: inline-block;"></div>
    <div class= "dropdown" index="$index + 1" ng-repeat = "cat in catData" id="{{cat.id}}" style="display: inline-block;">
        <div style="width: 8vw; display: inline-block; "></div>
        <button id = "{{cat.id}}Btn" style ="width:25px; height: 25px; border-radius: 50%; border: 2px solid rgb(9,37,129);" class="btn btn-default dropdown-toggle categoryButtons" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
        <ul class="dropdown-menu">
            <li ng-repeat="subcat in subcatData" ng-if="subcat.parent === cat.id" id="{{subcat.id}}" ng-click="article('{{subcat.url}}')">
                <a href ="" class="whole">
                    <span class="content">{{subcat.name}}</span>
                </a>
            </li>
        </ul>
    </div>
</div>

It basically gets categories from a database and displays them as dropdowns with each dropdown of a category having different subcategories which are also fetched from a database.

My question is this:

I would like to click a specific button when the page loads. There are 5 buttons each with dynamically rendered ids so for example, if if the id of the dropdown is Joe, the button corresponding to Joe is JoeBtn.

I have tried JQuery, and javascript click functions and they both didnt work. I made sure to add $(document).ready(...) for JQuery.

Community
  • 1
  • 1
Ayudh
  • 1,673
  • 1
  • 22
  • 55

0 Answers0