真的可以使用一些帮助/逻辑。
我想在 jquery 即兴的 href 上传递一个 elementid,然后可以使用它附加到目标 url。
那是; 以href开头:
<a class="link" href="javascript:;" elementid="66">Remove item</a>
我想要它,这样如果我单击此链接,它会将我发送到:remove-element.php?elementid=66
我的 javascript 看起来像:
<script>
function removeItem(id) {
var txt = 'Are you sure you want to remove this item?';
$.prompt(txt, {
buttons: {Yes: true, Cancel: false},
callback: function(accept) {
if (accept) {
window.location = "remove-element.php?elementid=x";
}
return false;
}
});
}
$('a.link').click(function() {
removeItem($(this).data('id'));
return false;
});
</script>