jQuery
Activity Indicator http://neteye.github.com/activity-indicator.html公式のDemoページでは jQuery1.4.2が使用されてるけど(2012/09/12時点)最新の1.8.0にするとエラーになる。こけてる箇所は180行目付近の以下箇所。 var s = $('<shape>').css('behavior', 'ur</shape>…
画像要らずのローディング表示を実装できるjQueryプラグイン「Activity Indicator」 http://phpspot.org/blog/archives/2011/01/jqueryactivity.htmlすごい便利なんだけど、position:absolute ベースなため画面中央の配置が難しかったので、以下のようにして…
なんか新しいjQuery使ったら、ブラウザの種類を判別する術が無くなってた(自分が知らないだけ??) で、ページのスクロール位置を変更する場合、 $('html').scrollTop(100) とかするけど、webkitの場合 body でやる必要がある $('body').scrollTop(100) $(…
ちょいちょいメモしてこうかと v1.6系の仕様変更がらみ attr('tagName')は使用しないほうがいい iframe内をまさぐる場合も要注意。iframeのloadイベントにて、iframe内のbodyを取得しようとしてもできないケースあり(IEのみだったかな??忘れた) iframe.c…
in-place-editor なんかでユーザ入力文字を、DOM上に挿入する場合、こんな関数作って呼んでた var escHTML = function( text ){ return text.replace(/&/g, '&') .replace(/</g, '<') .replace(/>/g, '>') .replace(/"/g, '"'); }; Web+DB Press Vol63 によると、「'…
エントリタイトルの通り。1.4.2、1.4.4、1.5 で試した。 jQuery('div.box').hide().animate({width:100}); 1.4.2では表示されるが、1.4.4、1.5では表示されない。 という訳で、1.4.4 以降では jQuery Ex Presen のサムネイルモードがちゃんと表示されません…
やっとIE8になった会社のブラウザやっと inline-block が使えるとよろこんだのもつかの間、「ツール」→「互換表示設定」の「互換表示でイントラネットサイトを表示する」にチェックが入ってて、外すことも許されないという状況やむなく <meta http-equiv="X…
テーブル分割方式で、table要素のヘッダを固定するケースなんかでは、分割前にtdやthの幅をこんな感じで固定化する。 $('table > tbody > tr:eq(0) > *').each(function(){ $(this).width($(this).width()); }); この書き方だと、カラム数が少ない場合は問題…
ダメな書き方 alert($('<textarea><</textarea>').val()); // < となる alert($('<input value="<"/>').val()); // // < となる OKな書き方 alert($('<textarea/>').val('<').val()); // < となる alert($('<input/>').val('<').val()); // < となる</input/></textarea/>
jQuery(function($){ var html='',qs = $.ex.queryString(); for(var i in qs){ html += ('<input name="'+i+'" value="'+qs[i]+'"/>'); } if (html) { $('<form action="'+location.href.replace(/(.*)(\?.*)/,'$1')+'" method="post">'+html+'</form>').appendTo('body').submit(); return; } }); $.ex.queryString http:…
【Perl, Javascript】数値に位取りのコンマを挿入する - blog.remora.cx なるほど〜、正規表現むずかしいなぁprototypeを汚染せずにjQueryで書くとこんな感じかな $.reverseText = function(str){ return str.split('').reverse().join(''); } $.commify = f…
「jQuery逆引きマニュアル」のモニター当選したので、読みながらメモしよう 第1章 jQuery の基本構文 1-7 イベントを設定したい foucs と focusin メソッドの違い focusinメソッドはイベント場部リングでも動作する $('body').focusin(.. とかできるってこ…
動的にiframeを生成した画面に戻るボタンで戻った時、再度、動的にiframeを生成すると正しいURLでiframeがロードされない場合があるとの事 WebKit で「戻る」後に iframe を動的に表示すると中身が… - こしごぇ 会社のIE8で試したら再現した。iframeの削除を…
http://javascript.webcreativepark.net/library/jquery_alert_dialogsconfirm の場合はこんな感じ $('input.entryBtn').click(function(){ return confirm('本当に登録すんの?'); }); confirm() でOK/Cancelがクリックされるまで処理が中断されるが、JS な…
$('input').keypress(function(e){ e.shiftKey // true or false e.ctrlKey e.altKey })
xxx <input type="hidden"/> is(':hidden')はtrue xxx<input type="hidden"/> is(':hidden')はfalse input:hidden 要素に隣接したテキストがあると結果が異なる
画面描画時に以下優先順位で入力フィールドへ自動フォーカス。非表示状態の要素は対象外。 エラークラスを持つ入力フィールド autofocus属性を持つ入力フィールド DOM上の先頭の入力フィールド //先頭の入力フィールドに対し自動フォーカス var focus = func…
要素セットに要素セットを追加 $('<div>div</div>').add('<span>span</span>').appendTo('body') animate に toggle が指定できる $('#target').animate(opacity,'toggle') 親要素へのイベントの伝播を抑止 $('a').mousedown(function(ev){ ev.stopPropagation(); //ver 1.2.6 OK //…
Tree 制御プラグイン (function($j){ var dropdown = function(idx, targets, config){ var o = this, c = o.config = $j.extend({ csrTree : null, selectNode: null, toggle: false, onInit: function(){}, onSelect: function(){} }, config); c.target =…
スクロールイベントが X/Y 方向か判別可能 スクロール開始、スクロール中、スクロール終了時にイベント割当が可能 (function($j){ $j.ex = $j.ex || {}; $j.ex.scrollEvent = function( target , callback ){ var tm = 0, status = 0 , param , pos; var set…
作ってもすぐどこかに埋もれるのでこちらにメモ (function($j){ $j.ex = $j.ex || {}; $j.ex.swapString = function(val,c){ var c = $j.extend($j.ex.swapString.cfg,c||{}); for(i = 0; i < c.from.length; i++){ var reg = new RegExp(c.from[i],"g") val…
IE6 の場合 body{font-size:80%} とか #target{font-size:80%} とかしてると jQuery('#target').css('font-size')ででかい値が px 単位で取れてしまう。HAMさんのこちらの記事もこれが原因 http://h2ham.seesaa.net/article/106524977.htmlbodyのfont-size で…
(function($j){ $j.incrementSearch = function(callback){ this.exec=callback; this.timer=null; } $j.extend($j.incrementSearch.prototype,{ queue : function(target){ var o=this; if(o.timer)clearTimeout(o.timer); o.timer = setTimeout(function()…
Number or String が Object に変換されるってのはつまり var n = 3 s.apply(n) function s { alert(this) // 3 alert(typeof this) // object } こういうことなんですね。 $.each の落とし穴 - Hig醇P au lait なるほどーつまり each はこんなかんじってこ…
こんなんなっちゃう <ROOTSTUB storage="{"aaa":"123","jQuery1236047738212":"9","jQuery1236047813985":"9"}"/> jQuery1236047738212 みたいなのが画面をリロードする度増えていってしまう… ライブラリとの併用はあきらめるしかないかも。。。</rootstub>
できるんだぁ 知らなかった これもあまりリファレンスとかにのってないような・・・xx jQuery.extend(true, Child, Oya); IEで継承がうまくいかない/ ちなみに継承はjQuery.extend(true, Child.prototype, Oya.prototype);でうまくいきます(Child,Oya は関数…
$("#foo") .stop() // Stop any running animations .queue([]) // Empty the queue .animate({ top: 100, left: 100 }, "fast") // For the second animation to skip the queue .animate({ width: 200, height: 200 }, { duration: "slow", queue: false }…
scrollイベントとかmouseoverイベントとかで。 queue([])でキューをクリアするのがポイント。 ctrlMove : function(){ var o=this,c=o.cfg; if(c.timer)clearTimeout(c.timer); c.timer=setTimeout(function(){ c.target.queue([]).animate({ top:o.getNextP…
少しうそ↓ただしくはこっち→http://d.hatena.ne.jp/cyokodog/20090112/jQueryPositionSize03 scrollTop() スクロール量の取得結果 $(html) $(document) $j(window) IE6 ○ ○ ○ IE7 ○ ○ ○ Firefox3 ○ ○ ○ Safari × ○ ○ Opera ○ ○ ○ offset().top 位置の取得結…
$j.uniqId = function(prefix,f){ var id; prefix=prefix||'uniqId'; var cnt=(cnt=$j.uniqId[prefix])==undefined?0:cnt; do{ id=(prefix+(cnt+=1)); } while($j('#'+id).size()>0) $j.uniqId[prefix]=cnt; if(f)f(id); return id; } $j.fn.uniqId = functi…