Yet Another attribute selector problem, where value has backslashes (ala full domain name, "DOMAIN\user")
I have searched this forum, Google, numerous boards, and my increasingly shrinking brain and I can't understand why this is happening. Consider the following (edited for brevity):
- <DIV id="divCurrentUsers">
- <DIV UserLogin="CMS Admin">CMS Admin</DIV>
- <DIV UserLogin="MYDOMAIN\juser">Joe User</DIV>
- </DIV>
- $("#divCurrentUsers>div")[0].outerHTML
- "<DIV UserLogin="CMS Admin">CMS Admin</DIV>"
- $("#divCurrentUsers>div")[1].outerHTML
- "<DIV UserLogin="MYDOMAIN\juser">Joe User</DIV>"
That's what we expect. And we expect this:
- $("#divCurrentUsers>div[UserLogin='CMS Admin']")
- {...}
- [0]: {object}
- context: {object}
- jquery: "1.5.1"
- length: 1
- prevObject: {...}
- selector: "#divCurrentUsers>div[UserLogin='CMS Admin']"
Neither of these work:
- $("#divCurrentUsers>div[UserLogin='MYDOMAIN\\juser']")
- {...}
- context: {object}
- jquery: "1.5.1"
- length: 0
- prevObject: {...}
- selector: "#divCurrentUsers>div[UserLogin='MYDOMAIN\juser']"
- $("#divCurrentUsers>div").filter(function() {return this.value=='MYDOMAIN\\juser';})
- {...}
- context: {object}
- jquery: "1.5.1"
- length: 0
- prevObject: {...}
- selector: "#divCurrentUsers>div.filter(function() {return this.value=='MYDOMAIN\juser';})"
I got the .filter idea elsewhere on this board, but it has no effect here. For grins, I've also tried this to no avail:
- $("#divCurrentUsers>div[UserLogin='MYDOMAIN\\\\juser']")
- {...}
- context: {object}
- jquery: "1.5.1"
- length: 0
- prevObject: {...}
- selector: "#divCurrentUsers>div[UserLogin='MYDOMAIN\\juser']"
Now, the following works, but I don't want to have to do this (note this works with or without the escaped backslash, but as soon as I put one character of the domain name, i.e. "N\\juser", it fails. FWIW, "UserLogin
$ " exhibits the same functionality in this example:
- $("#divCurrentUsers>div[UserLogin*='\\juser']")
- {...}
- [0]: {object}
- context: {object}
- jquery: "1.5.1"
- length: 1
- prevObject: {...}
- selector: "#divCurrentUsers>div[UserLogin*='\\juser']"
So, why aren't these searches returning the value with the string in front of the backslash in the value? My ego can handle someone pointing out the stupidly obvious if it will allow me to move on. For some reason, I don't want to punt on this one.