开发者

adding a confirmation box in jquery

开发者 https://www.devze.com 2023-03-31 20:44 出处:网络
I\'m trying to make code which will continuously show the confirmation box whenever a mouse movem开发者_JAVA百科ent occurs. I tried many but none are working for me.

I'm trying to make code which will continuously show the confirmation box whenever a mouse movem开发者_JAVA百科ent occurs. I tried many but none are working for me.

In my code, I need a confirmation box just having OK and Cancel.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0  
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script type="text/javascript">
$(function(){

$("#onediv").mousemove(function(evt){
alert("hai");
});

});


</script>
<style type="text/css">
div{

background-color:orange;
border:5px solid black;
height:400px;
margin:10px
}
</style>
</head>
 <div id="onediv">
sdfas
</div>

<body>
</body>
</html>


try to do this

$(document).mousemove(function(e) {    
//   do something
});


Just use the native Javascript confirm function:

if (confirm("Are you sure you want to do this?"))
{
    alert("Confirmed!");
}
else
{
    alert("Denied, foo!");
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号