【发布时间】:2012-01-10 20:49:29
【问题描述】:
我在页面中动态查找open标签的字符串,想用JQuery获取open标签对应的元素的文本。
例如,假设这是我的页面:
<h1 class="articleHeadline">
<NYT_HEADLINE version="1.0" type=" ">
The Arab Awakening and Israel
</NYT_HEADLINE>
</h1>
<author id="monkey" class="mainauthorstyle">
<h6 class="byline">
By
<a rel="author" href="http://topics.nytimes.com/top/opinion/editorialsandoped
/oped/columnists/thomaslfriedma/index.html?inline=nyt-per" title="More Articles
by Thomas L.Friedman" class="meta-per">
THOMAS L. FRIEDMAN
</a>
</h6>
</author>
我找到'<author id="monkey" class= "mainauthorstyle">' 开放标签字符串,并想得到$("author" id["monkey"] class["mainauthorstyle"]).text() --> By THOMAS L. FRIEDMAN。有没有一种简单的方法可以将打开的标签标记变成选择器?我应该用正则表达式解析它吗?
编辑:我事先不知道我想要什么元素。我的代码浏览页面并以'<author id="monkey" class= "mainauthorstyle">' 作为元素的开头。我事先不知道字面意思。我在任意网页上运行此代码。
【问题讨论】:
-
花点时间整理一下你的问题。如果您要寻求帮助,请在社区中进行一些投资。
标签: javascript jquery html jquery-selectors html-parsing