分类 "JavaScript" 下的文章

问题:希望找一个jquery的时间日期插件
解决:My97日期插件,有时间
方法:
一、在页面中导入脚本
<script type="text/javascript" src="/static/lib/My97DatePicker/WdatePicker.js"></script>
二、给html标签增加Wdate类
<input class="Wdate" type="text" placeholder="时间" />
三、给html标签增加click事件
$('.Wdate').click(function(){
WdatePicker({skin:"twoer", dateFmt:"yyyy-MM-dd HH:mm:ss"});
});
注:html标签class必须有Wdate

注:http://www.my97.net/dp/skin.asp

构造函数
Date.prototype.toHyphenDateString = function() {
var year = this.getFullYear();
var month = this.getMonth() + 1;
var date = this.getDate();
var hours=this.getHours();
var minutes=this.getMinutes();
var seconds=this.getSeconds();
if (month < 10) { month = "0" + month; }
if (date < 10) { date = "0" + date; }
if(hours < 10) { hours= "0" + hours}
if(minutes < 10) { minutes= "0" + minutes}
if(seconds < 10) { seconds= "0" + seconds}
return year + "-" + month + "-" + date + " "+hours+":"+minutes+":"+seconds;
};
timeShow();
setInterval(timeShow,1000);
function timeShow(){
var date=new Date();
var str=date.toHyphenDateString();
$('.time').text("当前时间:"+str);//jQuery方法,将时间显示在类为time的标签内
}

注:更新的内容http://it.xiaomantu.com/web/jquery/176.html

问题:在python后台如何获取websocket的send方法传递的消息
解决:
后台的on_message()方法就是为了获取websocket传递的消息的,而不是在on_open()方法中使用self.get_argument()或self.request

问题:如何设置radio的checked属性,如何取消radio单选框的选择
解决:使用jquery的prop方法,而不是attr方法,使用jquery的removeAttr方法,而不是removeProp方法
方法:

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>html5,js调用摄像头</title>
<script type="text/javascript" src="jquery-1.12.3.js"></script>
<style>
ul li:hover{
background:#f00;
cursor:pointer;
}
</style>
</head>
<body>

  • a
  • b
  • c
  • d

<span>A.</span>
<input id="choiceA" type="radio" value="A" name="choice_ans">
<span>B.</span>
<input id="choiceB" type="radio" value="B" name="choice_ans">
<span>C.</span>
<input id="choiceC" type="radio" value="C" name="choice_ans">
<span>D.</span>
<input id="choiceD" type="radio" value="D" name="choice_ans">
<script>
$(function(){
$('ul li').click(function(){
var val = $(this).text();
var tag = {'a':'A','b':'B','c':'C','d':'D'}[val];
console.log(tag);
$('input[name="choice_ans"]').removeAttr('checked');
$('#choice'+tag).prop('checked','true');
});
});
</script>
</body>
</html>

问题:jquery监听文件框内容变化,屏蔽一些敏感词
解决:使用js的oninput事件
方法:
<input id="name" type="text" oninput="func(this)" />
或jquery方法
$('#name').on('input', function(){
console.log(111);
});