忍者ブログ

カレンダー

03 2024/04 05
S M T W T F S
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

リンク

最新記事

カテゴリー

最新コメント

RSS

ブログ内検索

アーカイブ

[1]  [2]  [3

[PR]

×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

クリックで画像を90度回転

   $(function(){ $('img').click(function(){ var deg = parseInt($('#deg').val()); deg += 90; if (deg >= 360){ deg = 0; } $('img').css("transform" ,"rotate("+String(deg)+"deg)"); $('#deg').val(deg); }); });

拍手[1回]

PR

誕生日⇒年齢

<script type="text/javascript">
function _set(){
// birth[0]→year, birth[1]→month, birth[2]→day
var _birth = parseInt("" + $('#year').val() + affixZero($('#month').val()) + affixZero($('#day').val()) );
var  today = new Date();
var _today = parseInt("" + today.getFullYear() + affixZero(today.getMonth() + 1) + affixZero(today.getDate()));
$('#age').val(parseInt((_today - _birth) / 10000));
}
function affixZero(int) {
if (int < 10) int = "0" + int;
return "" + int;
}
</script>

拍手[0回]

onload jquery

$(function () { });

拍手[0回]

DOM:要素の追加

document.createElement("br");      :<br/>を作れ
document.createTextNode("test"); :testというテキスト
document.getElementById('id').appendChild( document.createElement("br") );

■input タグの追加に関するメモ
inputタグにname、onclickの挙動がIEでは不安定。
ex) element.setAttribute(name, value)

私の打開策:inputタグを直打ちする
       var html = document.getElementById('id').innerHTML;
       html += "<input type="button" name="hoge" value="push!" />";
       document.getElementById('id').innerHTML = html;

ブラウザを意識せずに打開できるので、好きです。

拍手[0回]

DOM:要素の削除

パターン1:削除する
document.body.removeChild(hoge);

パターン2:見えなくする
document.getElementById(id).style.display = 'none';
 
パターン3:中のHTMLをなくす
document.getElementById(id).innerHTML = '';

拍手[0回]



忍者ブログ [PR]

graphics by アンの小箱 * designed by Anne