$("*[id$='blahblah']")
is a good way but not perfect when
<asp:Button ID="chk" runat="server" Text="chk" />
<asp:Button ID="unchk" runat="server" Text="unchk" />
Is there a simple&&elegant way to select them precisely? (A complicated function like
if(id.indexOf('$')!=-1){/*blahblah*/}
is certainly not simple&&elegant)
Framework is your friend.
If you are using ASP.NET 4.0+, you can use the
ClientIDModeproperty of the control like this.If the mode is set to Static the ID of the control won’t change no matter what. ( ie, in Master Page and all ). Now you can elegantly call it like.
The other way which looks elegant to me is giving button CssClass and then using the selector for class. ie,
.classname