@H_502_1@我刚刚写了一个需要类名的确认删除功能:
jQuery(document).ready(function($) { $('.ConfirmDelete').click(function() { var question = $(this).attr('title'); if (question == '') question = 'Delete this record?'; return confirm(question); }); });
用法:
<input name="Delete" type="submit" value="Delete" class="ConfirmDelete" title="Delete #UsrName#?" />
我想将选择器从.ConfirmDelete更改为:
$('input:submit').attr('name','Delete').val('Delete')
含义:
如果提交按钮的名称为“删除”,它的值为“删除”,则继续进行,并假设他们要确认删除,而不要求他们具有ConfirmDelete类.
解决方法
$(':submit[name="Delete"][value="Delete"]').click(function() { return window.confirm(this.title || 'Delete this record?'); });