我很喜歡jQuery手機(和JS :)的新手,如果我說的東西看起來太簡單,那就不好意思。我已經通過互聯網搜索了兩天,並沒有找到解決方案。jQuery Mobile:listview(刷新)div標籤?
我想知道是否有一些功能與$(#someList).listview('refresh')相同,但對於div標籤。我有兩個div標籤,當我改變它的內容時,他們就失去了造型。
代碼:
function muestraFicha() {
var categoriaFicha = "Ciencia/Matemáticas";
var preguntaFicha = "Si un tren eléctrico sale de Valencia dirección Barcelona a 60Km/h con viento norte de 30Km/h ¿Hacia qué dirección saldrá el viento de su chimenea?";
var respuestaFicha = "En ninguna dirección, es un tren eléctrico y por lo tanto no despide humo";
var divRespuesta = "<div data-role='collapsible' data-theme='b' data-content-theme='c'>"
$("#fichaRespuesta").empty(); //vaciamos la ficha
$("#fichaRespuesta").append("<h4> Respuesta </h4>");
$("#fichaRespuesta").append("<p>" + respuestaFicha + "</p>");
$("#fichaPregunta").empty();
$("#fichaPregunta").append("<h3>" + categoriaFicha + "</h3>");
$("#fichaPregunta").append("<p>" + preguntaFicha + "</p>");
}
所以,在函數結束時,我需要的東西的.listview(「刷新」)或HTML只稱呼第一次函數被調用。
失去風格的div是fichaRespuesta和fichaPregunta。
謝謝。
哇!很好的回答,不僅解決了我的需求,而且幫助我提高了應用性能!謝謝你,賈斯帕。 –
不客氣。我只是再次查看上面的代碼,我意識到調用'.empty()。append()'與調用'.html()''相同。文件爲'.html()':http://api.jquery.com/html/ –
Jasper