var select = 'dd[lay-value=' + blog.UserId + ']'; $('#advertisementUserId').siblings("div.layui-form-select").find('dl').find(select).click();
另外记录上次选中,我选择用 sessionStorage,demo
<script> // 检测浏览器支持 if (typeof(Storage) !== "undefined") { // 存储 sessionStorage.setItem("lastname", "Smith"); // 检索 document.getElementById("result").innerHTML = sessionStorage.getItem("lastname"); } else { document.getElementById("result").innerHTML = "Sorry, your browser does not support Web Storage..."; } </script>
但是若 value 中含特殊字符等会导致查询报错,只需在 lay-value= 后加双引号即可
var select = 'dd[lay-value="' + pointOption + '"]';