Last active
April 7, 2021 22:39
-
-
Save jpneey/404ff7f52969c7b89ce731121c56a5ba to your computer and use it in GitHub Desktop.
Toggle text by using data attributes - jquery
This file contains hidden or 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
$.fn.toggleText = function() { | |
var altText = this.data("alt-text"); | |
if (altText) { | |
this.data("alt-text", this.html()); | |
this.html(altText); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment