버튼을 클릭 한 후 did you want delete this?
에 ok
과 cancel
의 두 가지 옵션을 요청하십시오. 사용자가 ok
을 클릭하면 값이 삭제됩니다. 사용자가 cancel
을 클릭하면 값을 삭제하지 마십시오. 이 사이트에서이 같이jQuery로 여러 옵션을 사용하는 경고
:
어떻게 jQuery를 사용하여이 작업을 수행하기 위해?
버튼을 클릭 한 후 did you want delete this?
에 ok
과 cancel
의 두 가지 옵션을 요청하십시오. 사용자가 ok
을 클릭하면 값이 삭제됩니다. 사용자가 cancel
을 클릭하면 값을 삭제하지 마십시오. 이 사이트에서이 같이jQuery로 여러 옵션을 사용하는 경고
:
어떻게 jQuery를 사용하여이 작업을 수행하기 위해?
<a href="#" id="delete">Delete</a>
$('#delete').click(function() {
if (confirm('Do you want to delete this item?')) {
// do delete item
}
});
jQuery를하지 않을 수 있습니다하지만 당신은 자바 스크립트에서
<html>
<head>
<script type="text/javascript">
function show_confirm()
{
var r=confirm("vote ");
if (r==true)
{
alert("ok delete"); //you can add your jquery here
}
else
{
alert(" Cancel! dont delete"); //you can add your jquery here
}
}
</script>
</head>
<body>
<input type="button" onclick="show_confirm()" value="Vote to delete?" /> <!-- can be changed to object binding with jquery-->
</body>
</html>Vot
'var에 R = 확인 ("투표"); if (r == true)'=='if (confirm ("vote"))' –
를 사용할 수 있다는 간단한 원리는, 상자의 유형은 confirm
하지 alert
입니다. confirm
은 사용자가 긍정 또는 부정적으로 프롬프트에 응답했는지 (즉, 을 클릭하면 true
이 반환되고 cancel
을 클릭하면 false
이 반환 됨) 결과를 나타내는 부울을 반환합니다. 이것은 jQuery에 적용 가능하지만 자바 스크립트에서도 더 광범위하게 적용됩니다. 당신은 말할 수 뭔가 같은 :
var shouldDelete = confirm("Do you want to delete?");
if (shouldDelete) {
// the user wants to delete
} else {
// the user does not want to delete
}
당신이 경고를 스타일이 플러그인을 확인하려면 다음 jquery-alert-dialogs합니다. 사용하기가 매우 쉽습니다.
UPDATE
jAlert('This is a custom alert box', 'Alert Dialog'); jConfirm('Can you confirm this?', 'Confirmation Dialog', function(r) { jAlert('Confirmed: ' + r, 'Confirmation Results'); }); jPrompt('Type something:', 'Prefilled value', 'Prompt Dialog', function(r) { if(r) alert('You entered ' + r); });
: 공식 주제 사이트는 현재 오프이다.
here is another source
현재 사이트가 다운되었지만 이것을 찾았습니다 : http://labs.abeautifulsite.net/archived/jquery-alerts/demo/ – Kayvar
@Kayvar가 내 대답을 업데이트 할 것입니다. 감사합니다 –
이것은 작동하지 않습니다. 참조 : http://jsfiddle.net/hP2Dz/ –
네,'''에서'''기호를 벗어 버리는 것을 잊어 버렸습니다. 이것을 확인하십시오 : http://jsfiddle.net/hP2Dz/4/ – Samich
경고를 위해'direction : rtl;'에서 사용하고'ok'와'cancel' 값을 바꿀 수 있습니까? –