Select more than one Element jQuery

html, jquery

Solution

$('#administratorUserName, #administratorPassword').mouseenter(function () {
      $(this).focus();
});

That should work. Note the comma in between. You also have to switch to using the object that was selected. Hence the change to `$(this).focus()` as opposed to specifically selecting again.

Problem

I need to select more than one element in the same page. For example, this: ``` $("#administratorUsername").mouseenter(function () { $("#administratorUsername").focus(); }); $("#administratorPassword").mouseenter(function () { $("#administratorPassword").focus(); }); ``` Also I need to select the `label` element to apply the same code. Ex: `$("#administratorUsername, label")`, `$("#administratorUsername - label")`. I don't know how to do it, and this is precisely my question.

Original source