I donβt know if you use Master / Content pages, but if so, then what I found works, gives your Master / Content pages an identifier.
If you just use one of them and assume that you provide the main page with the identifier "Mstr" and the page "Content" with the identifier "Cont", you can create JavaScript prefixes as follows:
var masterPrefix = "Mstr_", contentPrefix = "Cont_";
Then you can create a function called $getElement() that allows you to pass the identifier that you specify in your markup as follows:
function $getElement(id) { return $("#" + masterPrefix + contentPrefix + id); }
Then, according to your specific example, you can get the jQuery object for your runat = "server" div by doing the following:
var $slidingContent = $getElement("slidingContent");
I found this method to be a lifesaver when you get into big projects with heavy client-side scenarios.
Alternatively, if you don't like calling another function to return your object, you can always do this:
var $slidingContent = $('div[id$="slidingContent"]');
Here you just say give me a div that has an identifier ending in "slideContent".
source share