Reputation: 179
If i use another ID to get some data, it's no problem, but when i use "lbl_BlendCalc_1.1_I" as an ID i cannot get the text. (Changed this ID is not possible).
<input id="yes1" type="checkbox">
<label style="width: 100px;" id="lbl_BlendCalc_1.1_I">test</label>
$('input').change(function() {
if (this.checked) {
alert($("#lbl_BlendCalc_1.1_I").text()) ;
}
});
http://jsfiddle.net/wycvy/338/
I believe it is the ID that is doing something, but what i do not know.
Upvotes: 0
Views: 73
Reputation: 785
The character dot(.) is breaking the id. so if you dont want to change the id then escape it using backslashes '\\
'.
Upvotes: 2
Reputation: 15393
Id be broken if you using special characters like @!.
So we need to escaping the special characters with two backslashes(\\
).
$('input').change(function() {
if (this.checked) {
alert($("#lbl_BlendCalc_1\\.1_I").text()) ;
}
});
Upvotes: 1