开发者

using jquery with elements inside a asp:gridview

开发者 https://www.devze.com 2023-03-02 03:15 出处:网络
i 开发者_StackOverflowam trying to add some style with jquery to some elements inside a grid-view but jquery cannot identify those element. i am trying something like this

i 开发者_StackOverflowam trying to add some style with jquery to some elements inside a grid-view but jquery cannot identify those element. i am trying something like this

$("name").css("border", "3px solid red");

thanks


The problem is that .net creates big long ugly names by default. You may call your select "myinput" but .net turns that into something like "somebiguglylongcontainerid$myinput". So when you try to find just "#myinput" with jquery, you can't because it doesn't exist.

There are two solutions. If you are using a late enough version of .net, you can simply set ClientIDMode="static", and this will stop the .net renaming, so it will in fact be called "myinput".

The other solution is to inject the generated ID into your jquery with inline code. $("#<%=myinput.ID%>").css("border", "3px solid red");.

0

精彩评论

暂无评论...
验证码 换一张
取 消