0
我有一個something.php
將打印dropdownlist
的選項,\jquery.load( 「something.php」)都不盡如人意
然後我加載.php
文件,
$("#dropdownlist").load("something.php");
我加載後時,將顯示輸出,但是當我改變所選擇的值,在調試模式下我DIN不上的dropdownlist
選項看見一個selected="selected"
,我無法設置selectedvalue
到dropdownlist
也與
$("#dropdownlist").val("2");
任何人都知道爲什麼會發生這種情況,我該如何解決?
附加代碼
上.php
--print選項 -
while (isset($StatusArr[$loopCount])) {
if ($loopCount == 0) {
$selected = "selected='true'";
} else {
$selected = "";
}
echo "<option value='"
. $StatusArr[$loopCount][0]
. "' "
. $selected
. " >"
. $StatusArr[$loopCount][1]
. "</option>";
$loopCount ++;
}
---撥打.js
----
$('#select').load("../something.php", function (respond, fstatus, xhr) {
if (fstatus === "success") {
if (status !== "missing") {
$('#status').prop("selectedIndex", 3);
}
} else {
alert("Load data " + fstatus + "\n" + xhr.status + " " + xhr.statusText);
}
});
所以你想設置下拉列表中的第二個選項使用jQuery選擇?你能展示下拉列表的html代碼是怎麼樣的嗎? – chris97ong