chr():將 ASCII 碼轉換為字串符
chr(64);//輸出:@
ord():將字串符轉換為 ASCII 碼
ord(‘@’);//輸出:64
Chr(9)為Tab
Chr(10)為換行字元
Chr(13)為歸位字元(回車符號)
$list = explode(chr(13), $sn);
chr():將 ASCII 碼轉換為字串符
chr(64);//輸出:@
ord():將字串符轉換為 ASCII 碼
ord(‘@’);//輸出:64
Chr(9)為Tab
Chr(10)為換行字元
Chr(13)為歸位字元(回車符號)
$list = explode(chr(13), $sn);
Object.size = function(obj) { var size = 0; var key; for (key in obj) { if (obj.hasOwnProperty(key)) size++; } return size; }; // Get the size of an objectvar size = Object.size(myArray);
jqGrid JSON response:
{ //Custom JSON data: "userdata":{"lastSearchTime":"2015/01/01:16:00:00"}, //Normal JSON data: "page":1, "records":101, "rows":[...], "rowCount":10, "total":11 } loadComplete: function() { var obj = $('#list').jqGrid('getGridParam', 'userData'); }
$("#mylist").jqGrid({
…
colModel:[
...
{name:'value', width:100, align:'right', cellattr:valueAttr, ....},
...
],
…
});
function valueAttr(rowId, cellValue, rawObject, cm, rdata)
{
if (cellValue < 0) {
return ‘ style="color: red"‘;
} else {
return ‘ style="color: green"‘;
}
}
$.ajax({
type: ‘post’,
url: ‘page.php’,
data: $form.serialize() + ‘&data=’ + JSON.stringify(otherData),
dataType : ‘json’
})
<input type="checkbox" name="myCheckBox" value="checkBox1″>checkBox1
<input type="checkbox" name="myCheckBox" value="checkBox2″>checkBox2
<input type="checkbox" name="myCheckBox" value="checkBox3″>checkBox3
<script type="text/javascript">
<!–
$(document).ready(function(){
$("input[name=myCheckBox]").click( function () {
var Selected = $(this).val();
$("input[name=myCheckBox]").each(function(i){
if($(this).val() == Selected) $(this).prop("checked", true);
else $(this).prop("checked", false);
});
});
});
–>
</script>
<table id="myTable">
<tr>
<td>row0 cell0</td>
<td>row0 cell1</td>
<td>row0 cell2</td>
</tr>
<tr>
<td>row1 cell0</td>
<td>row1 cell1</td>
<td>row1 cell2
<input type="text" name="txt1″ id="txt1″ value="xxx">
<input type="text" name="txt2″ id="txt2″ value="yyy">
</td>
</tr>
</table>
付與表格欄位值:
document.getElementById("myTable").rows[0].cells[2]. innerHTML = "123″;
取得表格欄位中表單元素裡的值:
document.getElementById("myTable").rows[1].cells[2].firstChild.value;
document.getElementById("myTable").rows[1].cells[2].children[0].value;
安裝Firefox plugin:Firebug
<script type="text/jscript" language="javascript">
console.log(5+6);
</script>
觸發 select 事件
語法:$(selector).select();
例一:
$("input").select(function(){
});
例二:
$("input[type=text]").on(‘focus‘, function() {
$(this).mouseup(function(e){ e.preventDefault(); });//取消 on focus 觸發後的動作 $(this).css(‘background-color’,'#FFFFFF’).select();
}).on(‘blur‘, function() {
$(this).css(‘background-color’,'#E8E8E8′);
});
var start_time = ’2015/10/01 08:00:00′;
var end_time = ’2015/10/31 08:00:00′;
if(Date.parse(start_time).valueOf() > Date.parse(end_time).valueOf()){
alert("開始時間不能晚於結束時間!");
return false;
}