Search This Blog

2016/11/30

A quick way to get iPhone / iPad safari version 版本快速查询

You can also check version of other browsers by inputing below in address.
Or you can just click it.
通过点击下方代码链接即可获得现在使用中的浏览器版本。也可将其复制保存为书签后访问。

javascript:(function()%7Balert(navigator.userAgent);%7D)();

This JavaScript will make alert with message of your device info.
点击后将出现类似图片中的信息。

2016/11/29

A sample html page

Simple sample:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <title>Sample page title</title>
    <!--[if lt IE 9]>
        <script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
    <![endif]-->
</head>
  <body>
    <div>Output something</div>
  </body>
</html>

Other

meta:
<meta name="viewport"
      content="
          height = [pixel_value | "device-height"] ,
          width = [pixel_value | "device-width"] ,
          initial-scale = float_value ,
          minimum-scale = float_value ,
          maximum-scale = float_value ,
          user-scalable = ["yes" | "no"]
          " />

2016/11/28

CSS different child elements within a same parent同一阶层下的元素对应

HTML structure:
<div>
<span>element 1</span>
<p>element 2</p>
<p>element 3</p>
</div>

CSS:
div span {clear:both;}
div span + p {color: aquamarine;}
div span + p + p {color: blueviolet;}

2016/11/24

jQuery 取得form值

Code:
<form name="return" action="/" method ="post" id ="form">
<input type ="checkbox" name ="box1" group ="checkbox" checked="checked">
<input type ="checkbox" name ="box2" group ="checkbox">
<input type ="checkbox" name ="box3" group ="checkbox">
<select name="select1">
<option value="0">0</option>
<option value="1">1</option>
</select>
</form>


<script>
function get(){
// get value of selected checkbox
//取得checkbox被选中的项目

// 用,连接各个值
var check = jQuery('[group ="checkbox"]:checked').map(function(){
Return jQuery(this).val();
}).get().join(',');


jQuery('[group ="checkbox"]').each(function(I){
Var count = i + 1;
var check2=jQuery('[name="box'+count+'"]').map(function(){return count;}).get();
}
}
</script>

2016/11/09

When img failed show others|无法取得img时显示其他图片

Use onerror to show other img:
使用onerror来实现:
<img src="invaild path" onerror="script">

Ex./例:
<img src="invaild path" onerror="this.scr='right.img';">

Replace invaild img with right.img
图片不存在时,将图片替换成图片right.img

Or by jQuery/或者使用
<img src="invaild path" id="image">
<script>
$("#image").error().attr("src","right.img");
</script>