jQuery(document).ready(function($){
// When the Request button is clicked
$('.request-form-btn').on('click', function(){
// Set 'title' to the closest product's h3 text
var title = $(this).closest('.prod-i').find('h3').text();
// Set the value of the "name" field to the title we got above.
$('[name="modal_name"]').val( title );
});
});
1 回答
您所要做的就是在请求按钮上添加一个单击处理程序,找到'h3'的文本,并将模态表单的“name”字段值设置为该值 .
以此JavaScript为例
看来你正在使用高级主题,所以如果有的话,将其添加到网站的“自定义/正文/页脚”脚本部分,否则你需要使用众多“页眉/页脚”脚本插件中的一个可用的 .
您可以通过将JavaScript粘贴到该页面上的开发工具控制台来测试这一点 .