snippet

IE で select box を innerHtml() で書き換えるとボックスの大きさがリサイズされない。

一旦 hidden にして visible にする。

$('.class' + id).html(data).css({visibility: 'hidden'}).css({visibility: 'visible'});

何個かある select box の 1 個目だけ 2 番目の option を選択済みにする。

$('.class' + id + ':first').val($('.class' + id + ':first').find(':nth-child(2)').val());

radio button でいろいろ

symfony の helper だと id と name は勝手に指定してくれるけど class は指定してくれないので、name で value を取得するのが楽チン。

イベント登録

$("input[@name='radioButton']").click(function()
{
  ... snip ...
});

check された radio button の値を取得

if ($("input[@name='radioButton']:checked").val() == 0)
{
  ... snip ...
);

複数の element に同じイベントを登録

$('#foo, #bar').map(function()
{
  $(this).blur(function()
  {
    $('#buz').val($('#foo').val() - $('#bar').val());
  })
});
jquery.txt · Last modified: 2008/09/09 11:20 by topaz2