我摘录的js代码

1、修改样式

  document.getElementByIdx( "div1").style.display = "none";

 2、鼠标悬停图标变小手

  style="cursor:pointer"       显示为手
  style="cursor:wait"           显示为忙碌,通常为一个沙漏
  style="cursor:help"           显示为帮助,通常为一个问号或者为气球

 3、清空输入框的内容

  $("#div").val('');

4、输入框的默认值 输入后消失(说是主要用于搜索)

<input type="search" name="uname" placeholder="用户名" />

 5、怎么获取字符串中的数字并把数字转为整型数据

  var str = $('#msg').css("height")
  var strInt = str.replace(/[^\d]*/ig,"");
  var heightInt = parseInt(strInt);

 6、改变/还原元素的css样式

  移除css属性:$().removeAttr('style');

  移除css样式:$().removeClass('.xp');

  但是都没有直接把属性的值设为默认/自动有效果,如:

  $("#id").css("height","auto");

  $("#id").css("position","static");

7 把字符串转为整形数据

  php->intval();

  javascript->parseInt();

  parseInt 方法 返回由字符串转换得到的整数。 
  parseInt 方法返回与保存在 numString 中的数字值相等的整数。
  如果 numString 的前缀不能解释为整数,则返回 NaN(而不是数字)。
  parseInt("abc") // 返回 NaN。
  parseInt("12abc") // 返回 12。

                                by:yttsic

 

posted @ 2013-12-19 15:01  yttsic  阅读(137)  评论(0编辑  收藏  举报