I have to find an element by its id with jQuery. This element has the id:
txtHistoricalPricesDate
which would be easy to find under normal circumstances with the following:
var element = $('#txtHistoricalPricesDate');
but unfortunately, I’m working in an ASP.NET app, which helpfully renamed the element to:
ctl00_ContentPlaceHolder1_ucFundSearchResultsPanel_tabContainer_tabPriceTab_txtHistoricalPricesDate
rather than dirty the jQuery with that huge ridiculous ID, is there a way that I can tell jQuery to find the element with an ID that ends with txtHistoricalPricesDate?
Either use a class, or an attribute-ends-with selector, like this:
If you must use the above (but try and use a class) then prefix it with the element type, for example:
To use a class, just set its
CssClassproperty, for exampleCssClass="histPrices", then use a.classselector, like this:On any normal element use
class="", but since it’s an ASP.Net control it looks like, useCssClass, as that’s probably the WebControl property you’re dealing with.