Last active
December 17, 2015 21:58
-
-
Save a-ignatov-parc/5678110 to your computer and use it in GitHub Desktop.
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
| // Original code | |
| $('.__select-email .textfield') | |
| .removeClass('__required __invalid') | |
| .addClass('__' + error.type) | |
| .find('input[name="email"]') | |
| .after('<label class="error">' + error.text + '</label>'); | |
| // Short method | |
| var input = $('.__select-email .textfield') | |
| .removeClass('__required __invalid') | |
| .addClass('__' + error.type) | |
| .find('input[name="email"]'), | |
| $('<label class="error">' + error.text + '</label>') | |
| .insertAfter(input) | |
| .width(input.width()); | |
| // Another method | |
| $.fn.setElWidthAndInsertAfter = function(el) { | |
| return $(el) | |
| .width(this.width()) | |
| .insertAfter(this); | |
| } | |
| $('.__select-email .textfield') | |
| .removeClass('__required __invalid') | |
| .addClass('__' + error.type) | |
| .find('input[name="email"]') | |
| .setElWidthAndInsertAfter('<label class="error">' + error.text + '</label>'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment