Code Monkey home page Code Monkey logo

jquery.ah-placeholder's Introduction

#jQuery ah-placeholder Plugin

A plugin support placeholder attribute alternative.

HTML5の仕様にあるplaceholder属性を、未対応のブラウザでも擬似的に使えるようにするjQueryプラグインです。title属性に入れた文字列を、プレースホルダー用のテキストとして扱います。

##使い方 - Usage

サンプル:

<head>
<script src="./js/jquery.ah-placeholder.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function()
{
    $('.jq-placeholder').ahPlaceholder({
        placeholderColor : 'silver',
        placeholderAttr  : 'title',
        likeApple        : false
    });
});
</script>
</head>
<body>
<form action="" method="get">
    <input type="text" name="string" value="" title="プレースホルダーテキスト" class="jq-placeholder" />
    <input type="submit" name="submit" value="送信" />
</form>
</body>

###placeholderAttrオプション

placeholderAttrオプションがplaceholderの場合、placeholderに対応しているブラウザではスクリプトによる処理を行いません。

likeAppleオプションよりも優先されるため、placeholder対応ブラウザでlikeAppleオプションを有効にしたい場合は、placeholder属性以外(title属性など)を指定してください。

###likeAppleオプション

likeAppleオプションがtrueの場合、Focus時点でplaceholderが消えるのでなく文字入力を始めた時点で消える挙動に変更されます。

これは、iOSのMobile Safariや、Safari5.1以降のplaceholderの動作を再現したものです。

##変更履歴 - Change log

1.2 : placeholderAttrオプションを追加

1.1 : likeAppleオプションを追加

##クレジット - Credit

Copyright 2011, Ayumu Sato ( http://havelog.ayumusato.com )

jquery.ah-placeholder's People

Contributors

ahomu avatar mitsuruog avatar k1low avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.