大家好,想知道是否有人可以帮助我合并以下代码。我应该能够拥有更少的代码行,但不知道如何实现这一点。
$(document).ready(function () {
$(".question1").hover(function () {
$(this).append('<div class="tooltip"><p>1This is a tooltip. It is typically used to explain something to a user without taking up space on the page.</p></div>');
}, function () {
$("div.tooltip").remove();
});
$(".question2").hover(function () {
$(this).append('<div class="tooltip"><p>2This is a tooltip. It is typically used to explain something to a user without taking up space on the page.</p></div>');
}, function () {
$("div.tooltip").remove();
});
$(".question3").hover(function () {
$(this).append('<div class="tooltip"><p>3This is a tooltip. It is typically used to explain something to a user without taking up space on the page.</p></div>');
}, function () {
$("div.tooltip").remove();
});
});