1
我有以下的jQuery的ready函數運行實況查詢插件不可見的屬性選擇工作
$('[id$=txtCustomer]:visible').livequery(
function() { alert('Hello') },
function() { alert('World') }
);
我得到一個警報,第一次說「你好」,但功能不叫當我切換文本框的這種可見性。
請幫助。
我有以下的jQuery的ready函數運行實況查詢插件不可見的屬性選擇工作
$('[id$=txtCustomer]:visible').livequery(
function() { alert('Hello') },
function() { alert('World') }
);
我得到一個警報,第一次說「你好」,但功能不叫當我切換文本框的這種可見性。
請幫助。
livequery「match/nomatch」事件不適用於像「:visible」這樣的jQuery僞旋鈕。他們爲班級選擇工作。
一個簡單的解決方法是在顯示項目時添加一個類,並在隱藏項目時刪除類。
例如:
(HTML)
<input type="button" value="toggle"/>
<div id="item"
style="width:100px;height:100px;background-color:#ff0"
class="Visible">
</div>
(腳本)
$(function() {
$("#item.Visible").livequery(
function() {
alert("match");
},
function() {
alert("nomatch");
}
);
$("input").click(function() {
if ($("#item").is(":visible"))
$("#item").hide().removeClass("Visible");
else
$("#item").show().addClass("Visible");
});
});
的這個演示可以在這裏找到:http://jsbin.com/uremo
謝謝你的格式菲利普 – 2009-07-14 09:52:16