my question is this:

I have HTML code in multiple pages, on each of them I used a JQgrid (jquery grid) for display some data. I knew that on each of those pages, the element that holds the JQgrid is named as "LIST_xxx". Now I need to make a javascript that takes that element "LIST_XXXX" on each page and does some stuff. How could I search for an element by ID but only knowing its initial part (of the ID ,like i mentioned previously):

$('#list_[XXXX]')... --> The part surrounded by [] is variable on each page, i want to discriminate that.

I hope i made myself clear. Thanks.

推荐答案

Try

$('div[id^="list_"]')

It should work

Jquery相关问答推荐

子 li 元素的点击事件

如何在for循环期间上传文件

第一次单击后,Ajax addEventListener 停止工作

更改高亮 colored颜色

jquery如何判断ajax调用的响应类型

jQuery找到最近的匹配元素

使用 jQuery $.ajax() 时如何使用 GET 在请求正文中发送数据

用按钮切换显示/隐藏div?

JSLint 消息:未使用的变量

jQuery绑定到粘贴事件,如何获取粘贴的内容

从 iframe 访问父窗口的元素

如何使用 jQuery 显示忙碌指示器?

未捕获的 TypeError:data.push 不是函数

带有 jquery.animate() 的 CSS 旋转跨浏览器

如何通过js打开 Select 文件对话框?

带有 jquery 的 jsonp

JQuery - 如何根据值 Select 下拉项

如何重新加载/刷新 jQuery 数据表?

Uncaught TypeError: undefined is not a function on loading jquery-min.js

如何使用 jQuery Select 第一个父 DIV?