JS_语句_老版本

分类:N10_前端

标签:

需求:checkbox 的透明度
语句:visibility: visible;  opacity: 0;	

QQ链接跳转:业务01

需求:checkbox 选中
语句:	
  
	// $("[type='checkbox']").attr("checked",'true');//选中
	$("[value='"+ids+"']").prop("checked",'true');   //选中value值为ids 的checkbox为选中的状态
	$("[value='"+ids+"']").removeAttr("checked");  //移除选中


需求:判断checkbox 选中
语句:

for(var i=0;i

需求:同一列商品,之选其中一个。(如商品只能选择其中一种颜色)
语句:	



需求:点击选中,再次点击取消。
语句:	

需求:检查img 中的src 值是否为空。
语句:


需求:点击让下一级显示,并且其他的隐藏
语句:

需求:php 中输出JS跳转
语句:	echo"alert('登陆成功');location='huangying.html';"; 
		echo "";

需求:给当前导航li标签自动加active,有自动消失了【适合选项卡】
语句:  

需求:给小于10的数前面加'0';
语句:	
			function iTwo(n){
			if(n<10){
				return '0'+n;
			}else{
				return ''+n;
			}

			//三目运算符  写法
			function iTwo(n){
				return n<10 ?  '0'+n :  ''+n
		    };
	     
		


需求:时间戳转换为标准时间
语句:var unixtime = new Date(creattime*1000);

需求:将时间戳转换为日期
语句:	
         function formatDate(now) {   //将时间戳转换为日期
            var year=now.getFullYear();
            var month=now.getMonth()+1;
            var date=now.getDate();
            var hour=now.getHours();
            var minute=now.getMinutes();
            var second=now.getSeconds();
            return year+"-"+iTwo(month)+"-"+iTwo(date)+" "+iTwo(hour)+":"+iTwo(minute)+":"+iTwo(second);
           }

	        function iTwo(n){
	            if(n<10){
	            	return '0'+n;
		        }else{
		            return ''+n;
		         }
        
        输出:formatDate(unixtime)

需求:输出当前时间,并且自动走【可以定时】
语句:



需求:动态获取input的输入的值
语句:  
		 

需求:显示隐藏的两个方法
语句: 

需求:检查提交的表单
语句:
		输入后、失去焦点时验证		onkeyup、onblur
			提交时检查				onsubmit
   
 用户:	
 标题:
内容:
       ">
    需求:默认为选中,使用if判断  smarty中($smarty.post.advtypes的使用) 语句:selected<{/if}>>默认选中 说明:如果ajax的回调函数的执行中,会有反复的处理,可以使用的是点击触发。 说明:判断是不是等于,在js 中用==的是双等于。 说明:ajax 返回的值,也可以用js做判断,类似于在页面用if。如消息列表中的ajax返回的消息。 说明:标签的 target 属性中 有在指定的框架中打开,之前没有注意到的。 如:target="main_frame"  可以在main_frame 框架中打开。 需求:动态给页面的input赋值 语句:  需求:用Ajax 给图片排序 语句: " value="<{$items.listorder}>" class="input1">  //要改变的值 " value="<{$items.id}>" class="input2">  // 表中的id 需求:用form 表单,option ,input 提交数据 语句:
11 22 33 需求:点击调出菜单A,让图片加边框,让当前的显示,其余的隐藏。 语句:  需求:append 多行内容的方法 语句:var htmldata= "";   htmldata += "";   htmldata += "";   htmldata += "";   $(".append").append(htmldata); 需求:判断是否有选中的checkbox。如果有则底部变为蓝色,如果一个也没有则变为灰色。 语句: 需求:判断是否当前的checkbox 为点击,如果点击了,则改变其背景以及让checkbox变为选中。 语句: 需求:在li列表中插入html,可以给li排序 语句: 需求:无刷新删除图片。 语句: 需求:li列表,点击向下 语句: 需求:jquery.prop的使用 语句: 需求:mui的使用如果不能选择标签 语句: 需求:如果给div 加了mui-scroll-wrapper ,不能显示。 语句:给div加 style="margin-top:0px;position: fixed !important;" 需求:JS中一些小的应用列表 语句: 需求:ajxa 刷新当前页 语句:window.location.reload(); 需求:点击图片向下一步 语句: 需求:点击图片向上一步 语句: 需求:广告管理删除图片 语句: 需求:首页滚动插件如下: 语句: //滚动插件 (function($){ $.fn.extend({         Scroll:function(opt,callback){                 //参数初始化                 if(!opt) var opt={};                 var _this=this.eq(0).find("ul:first");                 var        lineH=_this.find("li:first").height(), //获取行高                         line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10), //每次滚动的行数,默认为一屏,即父容器高度                         speed=opt.speed?parseInt(opt.speed,10):500, //卷动速度,数值越大,速度越慢(毫秒)                         timer=opt.timer?parseInt(opt.timer,10):3000; //滚动的时间间隔(毫秒)                 if(line==0) line=1;                 var upHeight=0-line*lineH;                 //滚动函数                 scrollUp=function(){                         _this.animate({                                 marginTop:upHeight                         },speed,function(){                                 for(i=1;i<=line;i++){                                         _this.find("li:first").appendTo(_this);                                 }                                 _this.css({marginTop:0});                         });                 }                 //鼠标事件绑定                 _this.hover(function(){                         clearInterval(timerID);                 },function(){                         timerID=setInterval("scrollUp()",timer);                 }).mouseout();         }         }) })(jQuery); $(document).ready(function(){         $("#scrollDiv").Scroll({line:1,speed:500,timer:2000});//多行修改line的值就行,就是同时跳动多条。 });
  •  
需求:移出不需要的属性,用removeAttr() 方法 语句: 需求:获取所有的input 语句:$("input ") 需求:input框的checkbox 设置为透明: 语句:visibility: visible;  opacity: 0; 需求:diaplay中原生的与js的区别 语句: 需求: 语句: 需求:localStorage [本地存储] 语句: 需求:防止1次点击触发多次执行 语句: 需求:鼠标移入与移出执行的函数 语句: $(function(){     $(".weixin").mouseover(function(){         $(".erwei").css('display','block');     });     $(".weixin").mouseleave(function(){         $(".erwei").css('display','none');     }); }); 需求:添加、克隆,包含。 语句:                  {dede:field.product_pic/}           需求:页面涂鸦 语句:  修改=>javascript:document.body.contentEditable='true';docuent.designMode='on'; void  0 改回来=>javascript:document.body.contentEditable='false'; void 0 需求:判断是上下午 语句: today=new Date(); var day; var date; var hello; hour=new Date().getHours() if(hour < 6)hello='  凌晨好! ' else if(hour < 9)hello=' 早上好! ' else if(hour < 12)hello=' 上午好! ' else if(hour < 14)hello=' 中午好! ' else if(hour < 17)hello=' 下午好! ' else if(hour < 19)hello=' 傍晚好! ' else if(hour < 22)hello=' 晚上好! ' else {hello='夜深了! '} var webUrl = webUrl; document.write(' '+hello); 需求:给DIV加class 语句: function toRed() { var oDiv=document.getElementById('div1'); oDiv.className='box'; } 需求:表单验证 语句: 需求:.text() 与eq()的使用。 语句:     var text=$("#li2 a:eq(0)").text();     if(text){         $(".nav-r ul li:eq(0)").removeClass('active');     }     $(".nav-r ul li a").each(function(){         if($(this).text()==text){             $(this).parent().addClass('active');         }      }) 需求:replace() 方法用于在字符串中用一些字符替换另一些字符,或替换一个与正则表达式匹配的子串。 语句: 需求:  //收藏的实现 语句: 需求:填写6位的密码 语句:      需求:用鼠标滚轮滚动控制图片的缩小放大 语句: function bbimg(o){  var zoom=parseInt(o.style.zoom, 10)||100; zoom+=event.wheelDelta/12; if (zoom>0) o.style.zoom=zoom+'%'; return false; }

将鼠标放在图片上,点击一下,然后滚动鼠标滚轮试试看

 

 

 

  //统计输入框的字数 $(function() {  $(document).keyup(function() {  var text = $("#consult_content").val();  var counter = text.length;  $("#name_word").text(counter+'/120');  });     });    //offset()的使用 $(document).ready(function(){   $("button").click(function(){     $("p").offset(function(n,c){      newPos=new Object();         newPos.left=c.left+100;         newPos.top=c.top+100;         return newPos;     });   }); });

这是一个段落。


修改内容