Javascript 如何设置加载页面时默认单击的列表项

Javascript 如何设置加载页面时默认单击的列表项,javascript,jquery,html,html-lists,Javascript,Jquery,Html,Html Lists,我在页面加载时动态创建了一个listview,我想设置默认情况下要单击的第一个列表项,如何使用jQuery/javascript实现这一点 $(function () { // Give the below one, or use the perfect selector for your first <li> $("li").first().trigger("click"); }); 或者,如果您使用tag制作,则需要以不同的方式进行处理: $(function () {

我在页面加载时动态创建了一个listview,我想设置默认情况下要单击的第一个列表项,如何使用jQuery/javascript实现这一点

$(function () {
  // Give the below one, or use the perfect selector for your first <li>
  $("li").first().trigger("click");
});
或者,如果您使用tag制作,则需要以不同的方式进行处理:

$(function () {
  // Give the below one, or use the perfect selector for your first <select>
  $("select option").first().prop("selected", true);
});

@ᴜʀᴇsʜᴀᴛᴛᴀ 不是列表项吗?这是最简单的。英雄联盟