Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 改变<;部门>;CSS属性_Javascript_Jquery_Html - Fatal编程技术网

Javascript 改变<;部门>;CSS属性

Javascript 改变<;部门>;CSS属性,javascript,jquery,html,Javascript,Jquery,Html,我在JavaScript中有一个元素引用,如下所示: custom_div = document.createElement("div") 我想通过JavaScript将此元素的位置更改为绝对,并将底部对齐设置为0。我正在寻找建议。有很多方法可以做到这一点,但不建议直接操作DOM。使用或尝试。您只需使用: document.getElementById("div#example").style.position="absolute"; document.getElementById("div#

我在JavaScript中有一个
元素引用,如下所示:

custom_div = document.createElement("div")

我想通过JavaScript将此元素的
位置
更改为
绝对
,并将
底部
对齐设置为
0
。我正在寻找建议。

有很多方法可以做到这一点,但不建议直接操作DOM。使用或尝试。

您只需使用:

document.getElementById("div#example").style.position="absolute";
document.getElementById("div#example").style.bottom="0";

你试过什么?你在哪里卡住了?你的密码在哪里?您搜索过jQuery API吗?您刚刚创建了一个元素,除非您将它放在某个地方,否则它的样式实际上并不重要,但它将是
custom\u div.style.position='absolute'
等。可能重复: