Giter Club home page Giter Club logo

jquery-defaulttext's Introduction

jQuery defaultText plugin

VERSION SUPPORT

jQuery 1.4.2 or higher support only (uses 'delegate' method)

DESCRIPTION

defaultText is a jQuery plugin that sets values to empty input fields. It was built for code efficiency and minimal DOM traversal.

WHY

Most defaultText implementations are not practical and require more DOM traversals than necessary. This plugin focuses on speed and performance with event delegation options by providing an optional 'context' parameter.

USAGE

Give your tags a title attribute.

<input type="text title="enter your username" />

Simple example:

// Input field will now show "enter your username" when empty
// Input field will have a css class of "default"
// If you submit the form, the input will autoclear itself
// After autoclearing, the input field will automatically re-insert the title value

$.defaultText();

Example with options:

// All input fields inside a form will have defaultText behavior
// Empty inputs displaying defaultText will have a class of 'myClass'
// When #button2 or .link are clicked, inputs with default text will clear itself.
// Clearing allows for forms to be submitted without default text data.

$.defaultText({
	context: 'form',
	css: 'myClass',
	clearEvents: [
		{selector: '#button2', type:'click'},
		{selector: '.link3', type:'click'}
	]
});

jquery-defaulttext's People

Contributors

weixiyen avatar

Watchers

Roman Tishakov avatar James Cloos avatar

Forkers

szaboat

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.