Well, i understand my title is a bit confusing. I will state it clearly below with the example.
WebControls translate the tilde into the correct path when run on the server before rendering the html, you will need to use the full path or relative path in jQuery if you're changing the src on the fly.
You might want to have a property on the page with the root path eg: ApplicationRootURL and do something like this: