html5如何用脚本添加input控件

html-css09

html5如何用脚本添加input控件,第1张

1、动态创建input节点

2、往form中添加Input节点

示例:

<body>

<form id='form'>--定义form

</form>

<script>

var input = document.createElement('input') //创建input节点

input.setAttribute('type', 'text') //定义类型是文本输入

document.getElementById('form').appendChild(input )//添加到form中显示

</script>

</body>

<div style="position:absoluteleft:600pxtop:20px"><input type="text" name="nameid"></div>

left是到窗口左侧的距离

top是到窗口顶端距离

根据自己的需要设置

将插件下载下来后,你可以在页面里直接引入插件,比如:

<link href="插件css"/>

<script src="插件js"></script>

2. 也可以用node包去安装,然后用import 去引用

比如在vue里引入引入swiper:

安装:npm install vue-awesome-swiper --save

在main.js里全局注册:

Vue.use(VueAwesomeSwiper)

引入其css:

require('swiper/dist/css/swiper.css')

在模板里引入js:

import { swiper, swiperSlide } from 'vue-awesome-swiper'

在模板里注册组件:

components: {

swiper,

swiperSlide

}