1

I'm trying to click a button on a webpage.

<table class="table div-table list-pc bg-white" style='font-family: "gulim", sans-serif;'>
            <tr>
                <td colspan=2 align=left><input type="checkbox" name="check_all" id="check_all">SelectAll</td>
                <td colspan=2 align=right><input type="button" name="btn_delete" value="DeleteAll" onclick="javascript:GoCheck()"></td>
            </tr>          

I tried to do it as below but it didn't work.

document.getElementsByName("btn_delete").click();

Help me, please.

NubyShark
  • 143
  • 2
  • 11

1 Answers1

0

getElementsByName returns element collection, you need to take first element of this collection. Than it'll work.

document.getElementsByName("btn_delete")[0].click();
pavel
  • 26,538
  • 10
  • 45
  • 61