需要获取我单击按钮的行上字段的值

Need to get the value of a field on a row that I am clicking a button

我在 SharePoint 页面 (aspx) 底部有一个列表视图,每条记录都是提供支持的联系人。我有姓名、电子邮件地址和一个按钮,用于打开电子邮件并获取旁边的电子邮件地址。该按钮是通过 js 在屏幕上添加的,不是列表视图的一部分。按钮点击功能如何获取其左侧的地址?

一直在找啊找啊。

<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {  
    addButtons();
});
function addButtons(){
     var $t = $('#js-listviewthead-WPQ2').next().next().find('tr');
    $t.each(function(){
        $(this).append("<input type='button' value='Help' id='btnSub' onclick='javascript:openMail();'>");
    });
}
function openMail(){
    var emailString = "mailto:";
    var emailID = getEmail('SharePointName');
//alert(emailID);

    emailString += emailID ;
    emailString += "?Subject=SharePoint Site Support - Site=";
    emailString += _spPageContextInfo.webServerRelativeUrl;;
    //alert(emailString);
    location.href=emailString;
}
function getEmail(title) {
    var userEmail = "Steve.@Wi.gov";
    return userEmail;
}
</script>

我想获取电子邮件地址并将其附加到 emailString 以创建适当的 href。

我们可以使用下面的代码来实现,修改代码中的"listTitle"使其在一个列表视图web部件中工作。

<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {  
     addButtons();
});
function addButtons(){
    var listTitle="CustomList";
    $("table.ms-listviewtable[summary='"+listTitle+"']>tbody>tr").each(function(){
        $(this).append("<input type='button' value='Help' class='btnSub' onclick='javascript:openMail(this);'>");
    });
}
function openMail(btn){
    var emailString = "mailto:";
    var emailID = $(btn).prev("td").text();
    //alert(emailID);

    emailString += emailID ;
    emailString += "?Subject=SharePoint Site Support - Site=";
    emailString += _spPageContextInfo.webServerRelativeUrl;;
    //alert(emailString);
    location.href=emailString;
}
</script>