开发者

without wrapping jQuery search result

ASP.NET is changing id, name values according to control's parent control name. That's why i am searching id with JQUERY as below.

// $ is looking to the end of "id" attribute of input elements
$("input[id$='cbAddToNews']")

Only one element is returning by jQuery. But when i want to change the attribute, I'm using this syntax:

$($("input[id$='cbAddTo开发者_开发知识库News']")[0]).show()

Is there any way to do this without wrapping it with $(...[0]) ?


You should rather find out the actual ID being assigned to it via the ClientID property instead of using $=.

Also, if jQuery is already only returning one element, why do you try to limit it to the first one separately?


You can use classes instead. Assign a class to your ASP.NET element using CssClass="classname".

use $('input.classname') to select the element in jQuery.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜