我有一个网页上这个网站:.VAL()选择文本,而不是字符串值,当网页dinamically编辑HTML源
<select name="chapter_select" class="chapter_select">
<option value="http://www.example.com/chapter/1">Chapter 1</option>
<option value="http://www.example.com/chapter/2">Chapter 2</option>
<option value="http://www.example.com/chapter/3">Chapter 3</option>
<option value="http://www.example.com/chapter/4">Chapter 4</option>
<option value="http://www.example.com/chapter/5">Chapter 5</option>
<option value="http://www.example.com/chapter/6" selected="selected">Chapter 6</option>
</select>
而这个变量:
getInformationsFromCurrentPage : function(doc, curUrl, callback) {
//This function runs in the DOM of the current consulted page
var curChapName = $("select.chapter_select:first option:selected", doc).text();
var chapurl = $("select.chapter_select:first option:selected", doc).val();
callback({"name": name,
"currentChapter": curChapName,
"currentMangaURL": nameurl,
"currentChapterURL": chapurl});
},
}
问题是否都返回相同的文本值。 chapurl应该返回url,而不是文本值。这一直在网站修改他们的网站。
我知道我会非常挑剔,但这是扩展的开发手册,并且doc变量是必须的http://www.allmangasreader.com/dev.php只需查看getInformationsFromCurrentPage函数。它使用的是jQuery 1.4.2所以也许是这样的,奇怪的是其他网站就是这样工作的。
更新:服务器正在使用脚本(重写html)让我觉得下拉列表在顶部。我使用了一些选择器来获取源代码之后的正确选择。
我得到的URL,如果我删除的文档对象:http://jsfiddle.net/fs49g/6/ – 2012-08-08 02:59:29