如何将这类代码放入注销导航链接代码中?我刚开始使用jquery所以我有麻烦了.我需要你们的帮助伙计们。
这是我需要将其放在下面的代码:
<a href="#">Logout</a>这是代码:
<script type="text/javascript" src="Zebra_Dialog-master/public/javascript/zebra_dialog.js"></script>
<link rel="stylesheet" href="Zebra_Dialog-master/public/css/default/zebra_dialog.css" type="text/css">
<script>
$.Zebra_Dialog('<strong>Do you want to Logout?</strong>', {
'type': 'question',
'title': 'Non-uniformed Personnel (NUP)',
'buttons': [
{caption: 'Yes', callback: function() { alert('"Yes" was clicked')}},
{caption: 'No', callback: function() { alert('"No" was clicked')}},
{caption: 'Cancel', callback: function() { alert('"Cancel" was clicked')}}
]
});
</script>发布于 2014-01-15 16:28:25
可以使用.click()处理程序。
HTML
<a id="logout" href="#">Logout</a>JavaScript
$(document).ready(function() {
// show a dialog box when clicking on a link
$("#logout").on('click', function(e) {
e.preventDefault();
$.Zebra_Dialog('<strong>Do you want to Logout?</strong>', {
'type': 'question',
'title': 'Non-uniformed Personnel (NUP)',
'buttons': [
{caption: 'Yes', callback: function() { alert('"Yes" was clicked')}},
{caption: 'No', callback: function() { alert('"No" was clicked')}},
{caption: 'Cancel', callback: function() { alert('"Cancel" was clicked')}}
]
});
});
});发布于 2014-01-15 16:28:40
<a href="#" id="logout_button">Logout</a>而Javascript:
$('#logout_button').click(function(){
//whatever you want to happen when you click the button goes here
})发布于 2014-01-15 16:30:04
来自http://stefangabos.ro/jquery/zebra-dialog/:
>$(document).ready(function() {
// show a dialog box when clicking on a link
$(anchor).bind('click', function(e) {
e.preventDefault();
$.Zebra_Dialog('The link was clicked!');
});});
给你的标签一个身份,
<a href='#' id='logout'>logout</a>将上述代码中的“锚”替换为“#logout”。
https://stackoverflow.com/questions/21142792
复制相似问题