金曜日, 8月 31, 2012

クリックで表示を切り替える(単位変換など)

米国での長さの単位はきわめていまいましいことにすべてインチ・フィートです。

 ここで、インチ・フィートに要素を変換する jQuery スクリプトを示します。

 $(document).ready(function(){
  $(".millimeters").hide();
  $("#convertIN").click(function(){
   $(".millimeters").hide();
   $(".inches").show();
      });
  $("#convertMM").click(function(){
   $(".millimeters").show();
   $(".inches").hide();
      });
     });

JQuery であると容易に要素の表示を切り替えることができます。

 ... there was a question in the Reddit session to Obama whether the US would ever move to metric system.

PHP: 定数を扱う

プロジェクトごとの定数を扱うクラス Config\Constants の紹介です。 <?php namespace Config; class Constants {     public const DB_USER = "linguist...