如何设置页面加载时默认点击的列表项
How to set list item clicked by default when page loads
我有一个在页面加载时动态创建的列表视图,我想将第一个列表项设置为默认单击,如何使用 jQuery/javascript 来实现?
这样给:
$(function () {
// Give the below one, or use the perfect selector for your first <li>
$("li").first().trigger("click");
});
或者,如果您使用 <select>
标签制作它,则需要以不同的方式处理它:
$(function () {
// Give the below one, or use the perfect selector for your first <select>
$("select option").first().prop("selected", true);
});
我有一个在页面加载时动态创建的列表视图,我想将第一个列表项设置为默认单击,如何使用 jQuery/javascript 来实现?
这样给:
$(function () {
// Give the below one, or use the perfect selector for your first <li>
$("li").first().trigger("click");
});
或者,如果您使用 <select>
标签制作它,则需要以不同的方式处理它:
$(function () {
// Give the below one, or use the perfect selector for your first <select>
$("select option").first().prop("selected", true);
});