今天在寫jquery 套件時,因為我的套件會用到 http://jquerytools.org/download/ 的效果
在抓jquery tools 時不要把jquery 包進去,不然會引入兩個jquery,在套件裡面會有 $ === window.jQuery 為 false的問題
2012年7月19日 星期四
2012年7月9日 星期一
javascript 物件寫法
需產生物件後才能使用物件和其方法。
出錯:
正常:
var obj = { //少var 亦會出錯
a : {
a : function(){
} ,
b : (function(){
console.log( obj )
})()
},
b : (function(){
console.log( obj ) // 出錯
})()
}
正常:
var obj = {}
obj.a = {
a : '123' ,
b : '456' ,
c : function(){
return this.a + this.b ;
} ,
init : function(){
console.log( this ) ;
}
}
obj.a.init() ;
http://stackoverflow.com/questions/3455405/how-to-remove-a-key-from-a-javascript-object
刪除一個物件的key
delete thisIsObject[key];
出錯:
var obj = { //少var 亦會出錯
a : {
a : function(){
} ,
b : (function(){
console.log( obj ); // 出錯
})()
},
b : (function(){
console.log( obj ); // 出錯
})()
}
正常:
var obj = {}
obj.a = {
a : '123' ,
b : '456' ,
c : function(){
return this.a + this.b ;
} ,
init : function(){
console.log( this ) ;
}
}
obj.a.init() ;
出錯:var obj = { //少var 亦會出錯
a : {
a : function(){
} ,
b : (function(){
console.log( obj )
})()
},
b : (function(){
console.log( obj ) // 出錯
})()
}
正常:
var obj = {}
obj.a = {
a : '123' ,
b : '456' ,
c : function(){
return this.a + this.b ;
} ,
init : function(){
console.log( this ) ;
}
}
obj.a.init() ;
http://stackoverflow.com/questions/3455405/how-to-remove-a-key-from-a-javascript-object
刪除一個物件的key
delete thisIsObject[key];
2012年7月7日 星期六
union不同資料表不同型態資料到同一欄位
$sql =
(
SELECT new.new_podate AS order_date, new.new_top AS title, new.qq, new.new_add AS read_count, topname2.top2_name AS class_name, topname2.top_no, topname2.top2_no, guest_name AS author
FROM new, topname2
WHERE new.top_no = topname2.top_no
AND new.top2_no = topname2.top2_no
AND ( new.top_no=4 OR ( new.top_no=5 AND new.top2_no =1 ) OR ( new.top_no=8 AND new.top2_no =1 ) )
)
UNION ALL (
SELECT contant_date AS order_date, CONVERT(`detail`, CHAR) AS title, '' AS qq, '' AS read_count, '' AS class_name, top_no, top2_no, name AS author
FROM qanda
WHERE `top_no` =7 AND top2_no = 1
)
ORDER BY order_date DESC
LIMIT $start, 10
qanda的detail 是text 要轉換成char才能union
(
SELECT new.new_podate AS order_date, new.new_top AS title, new.qq, new.new_add AS read_count, topname2.top2_name AS class_name, topname2.top_no, topname2.top2_no, guest_name AS author
FROM new, topname2
WHERE new.top_no = topname2.top_no
AND new.top2_no = topname2.top2_no
AND ( new.top_no=4 OR ( new.top_no=5 AND new.top2_no =1 ) OR ( new.top_no=8 AND new.top2_no =1 ) )
)
UNION ALL (
SELECT contant_date AS order_date, CONVERT(`detail`, CHAR) AS title, '' AS qq, '' AS read_count, '' AS class_name, top_no, top2_no, name AS author
FROM qanda
WHERE `top_no` =7 AND top2_no = 1
)
ORDER BY order_date DESC
LIMIT $start, 10
qanda的detail 是text 要轉換成char才能union
2012年7月4日 星期三
absolute position的水平&垂直置中
http://birdegg.wordpress.com/2007/12/06/absolute-position的水平垂直置中/
在一已知 height & width 的 element,這個技巧蠻不錯的,原理是先設定
在一已知 height & width 的 element,這個技巧蠻不錯的,原理是先設定
top: 50%; left: 50%;,設定 element 的寬與高 height: 18em, width: 30em,再利用 negative margin 把 element shift 寬/高的一半 margin-left: -15em; margin-top: -9em
vcard {
border:1px solid #666666;
height:18em;
left:50%;
margin-left:-15em;
margin-top:-9em;
position:absolute;
top:50%;
width:30em;
}
訂閱:
意見 (Atom)