我有一個網頁上這個網站:.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