How to allow special characters in jQuery “contains”?
Original question asked
here .
So when this function is triggered it selects an item in a list via filtering elements with that class and with the text that the user provides through the var text.
If the above exists then it simply clicks that element, else show an error.
However if the user provides text like "hi(hello world)", this would be seen by jQuery as part of the function and not text, so it doesn't work.
So any special characters like "!/-()" will be seen as part of the function and not text.
This has really bugged me. The only solution I can see is to store the parameters in an hidden field and call it that way. Appreciate any replies!
- function selectListItems(Parameters) {
- var text = Parameters[1];
- var tdtext = $(".childNode").filter(function () {
- return $.text([this]) == Parameters;
- });
- if (tdtext && tdtext.length > 0) {
- tdtext.click();
- } else {
- alert("Error Coming")
- showErrorConfirmBox();
- }
- }