使用jquery/js在同一html页面中向用户输出消息

output a message to a user in the same html page using jquery/js

本文关键字:用户 消息 输出 html jquery js 使用      更新时间:2023-09-26

我想在同一个html页面中向用户输出一条消息,以确认他们选择的日期。我不想要一个提醒框,只是为了在他们所在的页面上显示它。

我以为可能是这样的,但我不确定:

document.writeln("You have selected: " + dateText);
 $('body').append("You have selected: " + dateText);

您可以将"主体"选择器替换为您想要的的任何其他元素

如果元素有id,那么如果它是类".class_element",则执行"#id_element

要了解有关选择器的更多信息,请执行以下操作:http://api.jquery.com/category/selectors/

有很多方法可以做到这一点。这里有一个:

$(".message").text("You have selected: " + dateText);
<div class='message'></div>

或者,如果您正在进行通知,也可以使用这些插件:

http://needim.github.com/noty/

http://www.red-team-design.com/wp-content/uploads/2011/07/cool-notification-messages-with-css3-and-jquery-demo.html#

我一直在用它们。省事了。Idk,只是说:)