HTML文件中的Javascript
我正在修改一个html文件,我需要帮助。它的头部是一堆javascript,它们创建了一些按钮,所有按钮都被标记为id=“#content” 然后在正文中,它简单地用HTML文件中的Javascript,javascript,html,button,Javascript,Html,Button,我正在修改一个html文件,我需要帮助。它的头部是一堆javascript,它们创建了一些按钮,所有按钮都被标记为id=“#content” 然后在正文中,它简单地用 我想能够独立地移动按钮(把它们放在桌子上)。我该怎么做 守则: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head>
我想能够独立地移动按钮(把它们放在桌子上)。我该怎么做
守则:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content = "height = device-height, width = 420, user-scalable = no" />
<title>Direct Current GUI</title>
<script type="text/javascript" src="/webiopi.js"></script>
<script type="text/javascript">
webiopi().ready(function() {
var content, button;
content = $("#content");
// create a "FORWARDS" labeled button for GPIO 7
button = webiopi().createGPIOButton(7, "FORWARDS");
content.append(button); // append button to content div
// create a "REVERSE" labeled button for GPIO 8
button = webiopi().createGPIOButton(8, "REVERSE");
content.append(button); // append button to content div
});
</script>
</head>
<body>
<table>
<tbody>
<tr><td id="content"></td></tr>
</tbody>
</table>
</body>
</html>
直流图形用户界面
webiopi().ready(函数()){
var内容,按钮;
内容=$(“#内容”);
//为GPIO 7创建标记为“转发”的按钮
button=webiopi().createGPIOButton(7,“转发”);
content.append(按钮);//将按钮追加到content div
//为GPIO 8创建一个带“反转”标签的按钮
button=webiopi().createGPIOButton(8,“反向”);
content.append(按钮);//将按钮追加到content div
});
您可以将按钮放在任何您喜欢的地方,要更改的行如下所示:
webiopi().ready(function() {
var button;
// create a "FORWARDS" labeled button for GPIO 7
button = webiopi().createGPIOButton(7, "FORWARDS");
$('#select-an-element-here').append(button); // append button to content div
// create a "REVERSE" labeled button for GPIO 8
button = webiopi().createGPIOButton(8, "REVERSE");
$('#select-an-element-here').append(button); // append button to content div
});
$(“#在此处选择一个元素”)
位可以针对页面上您喜欢的任何元素
例如:
<p id="example1"></p>
<div id="example2"></div>
我不太明白你想要什么…使用CSS来定位你的按钮,而不是表格。这很有效!当我读到你的留言时,我才开始这样做。非常感谢
webiopi().ready(function() {
var button;
// create a "FORWARDS" labeled button for GPIO 7
button = webiopi().createGPIOButton(7, "FORWARDS");
$('#example1').append(button);
// create a "REVERSE" labeled button for GPIO 8
button = webiopi().createGPIOButton(8, "REVERSE");
$('#example2').append(button);
});