Declare the escape function for jquery at first
$.escape = function(str) { return str.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~]/g, '\\$&'); };Example code
// the value contain special character var searchValue = 'your-value*'; // this is safe with escape var list1 = $('[value="' + $.escape(searchValue) + '"]'; // this may error without escape var list2 = $('[value="' + searchValue + '"]';Try to type the input
This is escaped value
Post a Comment