0
我製作了以下代碼來轉換所有必須應用jquery.ui樣式的所有a
元素,input type="submit
元素,button
元素和accordion div。迭代DOM元素並應用jquery-ui
我已經使用道具(「類型」)和標記名找出我循環什麼控制:
$(function() {
$('body *:not(script, style, noscript)').each(function() {
var t = $(this).prop('type');
if (t != undefined && t !="") {
if (t.indexOf("select") != "-1") {
$(this).combobox();
}
else if (t.indexOf("button") != "-1") {
$(this).button();
}
}
if ($(this).get(0).tagName == "DIV" &&
$(this).get(0).id != undefined &&
$(this).get(0).id.toUpperCase() == "ACCORDION") {
$(this).accordion({ collapsible: true });
} else if ($(this).get(0).tagName == "A" ||
($(this).get(0).tagName == "INPUT" &&
$(this).prop('type') == "submit")) {
$(this).button();
}
});
});
顯然,這是工作真棒。這個jquery就緒函數包含在我的asp.net mvc佈局頁面中,當我添加一個新的控件時,它是jQuery-ui呈現的。
但問題是。你有沒有做過這樣的事情?有更好的方法嗎?
呀進出口使用自動完成 –
大答案的方式;) –
謝謝,很高興,如果它幫助你;) – rd3n