Watermark asp:Login control Username and Password fields
I'm trying to watermark the asp:Login controls' User开发者_如何学Pythonname and Password fields with jQuery, I've tried various ways of referencing the control ID:
$('#<%=ClientID.Login1_UserName %>').watermark('watermark', 'Username');
I have tried moving the ClientID, Login1 and UserName around and changing the selectors to and from userscores and periods...
Any ideas?
Good old jQuery selectors ;)
$("input[name*='UserName']").watermark('watermark', 'Username');
$("input[id$='_UserName']:first").watermark('watermark', 'Username');
If you have an
<asp:TextBox ID="Login1_UserName" ... >
then your jquery code needs to look something like this
<script type="text/javascript">
<!--
$(document).ready(function() {
$('#<%= Login1_UserName.ClientID %>').watermark('watermark', 'Username');
}
// -->
</script>
although @Gogster had a very good suggestion as well--to avoid the <% %> tags altogether, which in my opinion is a bit more elegant and no less difficult to understand.
精彩评论