layerプラグインselect標準値を選択する方法
再度コードを変更する時、都市のプルダウンリストはデータベースから調べられたので、この時に以前使った方法を思い出しました。
レンダリングされていない要素はどのように値を設定しますか?そしてlayerをレンダリングしたページスタイルを、新しくレンダリングします。
例:[ラユイレンダリングドキュメント](http://www.layui.com/doc/modules/form.html#render)
レンダリングされていない要素はどのように値を設定しますか?そしてlayerをレンダリングしたページスタイルを、新しくレンダリングします。
例:[ラユイレンダリングドキュメント](http://www.layui.com/doc/modules/form.html#render)
$("#userName).val(" ");
...
$("#city").val(" ");
... , ,
form.render(); //
form.render('select'); // select
次の廃棄!!!!!!!!!!!!!!
/**
* layui:select ,
* ps:
* @param id
* @param :str
*/
function layuiSelected(id,str){
//0、 select
$("#"+id).attr("value",str);
//0.1 select option selected
$("#"+id).children("option").each(function(){
if ($(this).text() == str) {
$(this).attr("selected","selected");
}else{
if ($(this).attr("selected") == "selected") {
$(this).removeAttr("selected");
}
}
});
//1、
$("#"+id).siblings("div[class='layui-unselect layui-form-select']").children("div[class='layui-select-title']").children("input").val(str);
//2、 , dl dd
$("#"+id).siblings("div[class='layui-unselect layui-form-select']").children("dl").children("dd").each(function(){
if ($(this).text() == str){
if (!$(this).hasClass("layui-this")) {
$(this).addClass("layui-this");
$(this).click();
}
return true;
}else{
if ($(this).hasClass("layui-this")) {
$(this).removeClass("layui-this");
}
}
});
}
以上のlayerプラグインselectのデフォルト値を選ぶ方法は、小編集が皆さんのすべての内容を共有することです。参考にしていただければと思います。どうぞよろしくお願いします。