查找以id开头的html元素 [英] Find html element which id starts with

查看:260
本文介绍了查找以id开头的html元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是这个

我在多个页面中都有HTML代码,在每个页面上我都使用JQgrid(jQuery网格)来显示一些数据.我知道在每个页面上,保存JQgrid的元素都被命名为"LIST_xxx".现在,我需要制作一个JavaScript,在每个页面上使用该元素"LIST_XXXX"并执行一些操作.我如何才能通过ID搜索元素,但仅知道其初始部分(如我之前提到的那样):

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.

推荐答案

尝试

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

应该可以

这篇关于查找以id开头的html元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆