Created
March 4, 2013 21:15
-
-
Save Jerph/5085737 to your computer and use it in GitHub Desktop.
jquery plugin for accessing val(), or if that's empty, text(). Also calls the write version of both functions. Useful for changing the displayed text on buttons that can be either inputs or links.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.fn.valOrText = function (textString) { | |
if (textString === undefined) { | |
if (this.length == 0) | |
return this.val(); | |
else | |
return this.val() || this.text() | |
} else { | |
this.val(textString); | |
return this.text(textString); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment