我想在 jquery 中创建一个 if / else 语句,并弹出一个警报框,并根据我选择的 div 的背景颜色应该改变什么。
IE)
我有一个状态灯,当我按下它时,我会收到一个警报,如果我按下 OK,它会改变颜色,如果我按下 Cancel,颜色不会改变。
我怎么做?
提前致谢。
这就是代码现在的样子,
HTML
<div id="checklistItem">
<div class="status1">
<p class="item1"> Sample item </p>
</div>
<div class="itemInfo1"></div>
</div>
CSS
.status1{
height:15px;
width:15px;
border-radius:15px;
background:red;
position:relative;
top:20px;
left:10px;
cursor:pointer;
}
jQuery
$(document).ready(function() {
$('.status1').click(function(e) {
e.preventDefault();
if (window.confirm("Are you sure?")) {
}
});
});