1

I have a div that only shows when I press a button, but I also have a menu with anchor link to that div, but it only works when the div is not hidden. Since the div only shows when I press the button, is there any way to "press" or simulate the button click with a function?

<ul class="navList">
      <li><a href="#tools"><b>Tools</b></a>
        <div>
          <a href="#1">Calculate SubGhz channel</a>
        </div>
      </li>  
</ul>

<button class="collapsible">Calculate SubGhz channel</button>
   <div class="content">
    <br>
    <table>
        <tr>
            <td class="labels">Page:</td>
            <td><input class="labels" type="number" id="channel" value="28"></td>
            <td></td>
            <th class="label"rowspan="2">Output:</th>
            <th class="result"rowspan="2"><output id="resultSubGHZ"></th>
        </tr>
        <tr>
            <td class="labels">Channel:</td>
            <td><input class="labels" type="number" id="page" Value="0"></td>
            <td><input type="button" onclick="CalculateSubGhzPage()" value="Calculate"></td>
        </tr>
    </table>
    <br>
   </div>

3
  • 2
    button.click() Commented Sep 13, 2019 at 16:42
  • Hi! If you could post a bit of your code we can give you a specific example Commented Sep 13, 2019 at 16:46
  • 1
    @eponini updated post with some code Commented Sep 13, 2019 at 16:57

1 Answer 1

2

Maybe like This:

function click_button(_id){
  document.getElementById(_id).click();
}

click_button('btn');
<input id="btn" type="button" value="ClickMe" onclick="alert('Welcome');"/>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.