Reputation: 11243
A third-party control creates an element with an id that looks like:
aspxgv_1803_0_cell1_9_Attribute1^ubd
I need to get the value of this element but jquery seems to have issues with the illegal "^" in the id.
var fieldId = 'aspxgv_1803_0_cell1_9_Attribute1^ubd';
var fieldValue = $('#' + fieldId).val(); // <-------- function stops
How can I get the value of this element?
Upvotes: 2
Views: 119
Reputation: 5039
If you want a jQuery object of a DOM element you can always just pass the element to the $ function rather than a selector.
var fieldId = 'aspxgv_1803_0_cell1_9_Attribute1^ubd';
var fieldValue = $(document.getElementById(fieldId)).val();
Here's an example using this code to return the html of the jQuery object. http://jsfiddle.net/AZgwm/
Upvotes: 3
Reputation: 144659
You can escape the character.
var fieldValue = $('#aspxgv_1803_0_cell1_9_Attribute1\\^ubd').val();
Upvotes: 4