Created
March 3, 2012 04:11
-
-
Save elijahmanor/1964301 to your computer and use it in GitHub Desktop.
Find the jQuery Bug #8: Solution
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
| <form id="personForm" name="personForm" method="post" | |
| action="/Demo/jsf/main.jsf;jsessionid=0596FB948C236D0FFC16227FC10A0C23" | |
| enctype="application/x-www-form-urlencoded"> | |
| <div class="field"> | |
| <label>Last Name</label> | |
| <input id="personForm:lastname" name="personForm:lastname" type="text" value="" /> | |
| </div> | |
| <div class="field"> | |
| <label>First Name</label> | |
| <input id="personForm:firstname" name="personForm:firstname" type="text" value="" /> | |
| </div> | |
| <div class="field"> | |
| <label>Address</label> | |
| <input id="personForm:address" name="personForm:address" type="text" value="" /> | |
| </div> | |
| <!-- ... more HTML ... --> | |
| </form> |
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
| // <input id="person.name" name="person.name" type="text" /> | |
| $( "#person\\.name" ).addClass( "highlight" ); // Success | |
| // <input id="person:name" name="person:name" type="text" /> | |
| $( "#person\\:name" ).addClass( "highlight" ); // Success | |
| // <input id="person$name" name="person$name" /> | |
| $( "#person\\$name" ).addClass( "highlight" ); // Success |
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
| String.prototype.escapeSelector = function() { | |
| return this.replace( /([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g, | |
| "\\$1" ); | |
| }; | |
| $( document ).ready( function() { | |
| $( "#" + "personForm:firstname".escapeSelector() ) | |
| .addClass( "required" ); | |
| }); |
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
| $( document ).ready( function() { | |
| $( "#personForm\\:firstname" ).addClass( "required" ); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment