javascript - 需要 jquery 和 css 提示 $("elemet").css();
问题描述
我正在尝试将形状向下移动 200px $("#shape").css("top","200px");
,但它不起作用,有什么建议吗?
> <style type="text/css">
> #shape{
> width: 200px;
> height: 200px;
> background-color: red;
> display: none;
> position: :relative;
>
> }
>
> </style>
<div id="shape"></div>
<script type="text/javascript">
//var start=new Date().getTime();
function appear(){
$("#shape").css("top","200px");
$("#shape").css("display","block");
start=new Date().getTime();
}
</script>
解决方案
这样做
<!DOCTYPE html>
<html>
<head>
<title>your title</title>
</head>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>
<style type="text/css">
#shape{ width: 200px; height: 200px; background-color: red; display: none;
position:relative;
}
</style>
<body>
<div id="shape"></div>
<script type="text/javascript">
function appear(){
$("#shape").css("top","200px");
$("#shape").css("display","block");
start=new Date().getTime();
}
appear()
</script>
</body>
</html>
推荐阅读
- qt - 使用 Qt Creator 调整应用程序的大小是错误和滞后的
- postgresql - Ruby on Rails:使用 PostgreSQL 处理数据库连接失败/超时
- deep-learning - 为什么上下文向量没有传递给解码器的每个输入
- postgresql - 从 SQL Server 迁移到遇到 GUID、VARCHAR、UUID 问题的 Aurora PostgreSQL
- swiftui - 如何在 SwiftUI 中动态推送视图或呈现视图?
- java - 找到给定数字的最大素数
- java - 我应该按照 Java 约定将最终的“原子…”成员字段命名为常量(全部大写)吗?
- sass - Getting scss parse error in running storybook on svelte
- ethereum - 如何在不使用设置 msg.value 的情况下将资金从 msg.sender(amount) 转移到收件人地址
- javascript - 我需要帮助以使此导航栏在响应式折叠时全屏显示