使用onclick在javascript中获取输入标记中每个值的值

I have a loop of button and input tags

    while($row = mysqli_fetch_array($notifqry))
    {
        extract($row);
        if($type_of_notif == '1')
        {
        echo '<button class="dropdown-item"  onclick="notifview()">New Announcement!</button>';
        echo '<input type="text" id="notifid" name="notifid" value="'.$notifid.'">';

        }
    }

the button/links

and in my javascript

function notifview() {
var notifid = $('#notifid').val();
alert(notifid);
}

however, if I click the different button/links I only get the first row id only like this even i click the button w/ value of 3 or 4

enter image description here

id's need to unique for every input field. Also, if multiple input fields are created dynamically you will need to use event delegation to determine which button was clicked and then correspondingly extract that value.