‘壹’ 怎样用js选中图片带上ID
使用一个隐藏域<input type="hidden" value="" id="picid">再写个JS函数:function getpicid(id){ document.getElementById("picid").value=id}在每个图片上加上动作onclick="getpicid(不同图片的id)"图片的id可以是编号,图片地址等。在提交到的页中读取picid的值即可。 如果不用js也可以在每张图片前放单选按钮Name属性相同,value分别为不同图片的id或地址。如:<input type="radio" name="picid" value="图片1id或地址" /><input type="radio" name="picid" value="图片2id或地址" /><input type="radio" name="picid" value="图片3id或地址" />.....点击单后选提交,由于单选按钮只传递一个值,提交后获取picid值即可。
‘贰’ 用js实现一个页面可以用键盘左右方向键控制两张图片切换
用js的 event.keyCode来获取方向键。
从网上你可以查到左右方向键对应的keyCode值,这样你就能获取到左右键点击事件了。
然后当左右键点击的时候,触发显示和隐藏对应图片的功能。
图片的显示和隐藏,你可以用js给对应的图片添加显示或者隐藏的css。
这样就能实现你要的效果了
‘叁’ echarts.js 一个页面如何加载多个表 我想加载两个饼图 为什么只出来一个 求大神解救
<body>
<input type="button" value="TestEcharts" onclick="showLine()" /><br />
<input type="button" value="RadarEcharts" onclick="showRadar()" />
<div id="stackbar" align="center"
style="height: 260px; width: 30%; line-height: 260px; border: 1px solid blue; padding-left: -80px;">[可视化数据图例1...]</div>
<div id="radarbar" align="center"
style="height: 260px; width: 30%; line-height: 260px; border: 1px solid green; margin-top: 10px;">[可视化数据图例2...]</div>
分开初始化,.init(div);
function showLine() {
var echartBar = echarts.init(document.getElementById("stackbar"));
var option1 = {
title:{
text:'test',
subtext:'折线图测试',
x:'center',
y:'top',
textAlign:'center'
},
legend:{
data:['ThisWeek', 'LastWeek', 'FutureWeek'],
x: 'center',
y: 'bottom'
},
tooltip:{
//show: true, 默认添加tip即显示
trigger: 'item',
axisPointer:{
show: true,
type : 'cross',
lineStyle: {
type : 'dashed',
width : 1
}
}
},
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
axisLabel:{
textStyle:{
fontSize: 8
}
}
},
yAxis: {
type: 'value',
axisLabel:{
textStyle:{
fontSize: 5
}
}
},
series: [{
name: 'ThisWeek',
type: 'line',
//xAxisIndex: 1,
data: [820, 932, 901, 934, 1290, 1330, 1320]
},
{
name: 'LastWeek',
type: 'line',
data: [920, 832, 801, 834, 1090, 1130, 1120]
},
{
name: 'FutureWeek',
type: 'bar',
data: [520, 432, 401, 434, 690, 730, 720]
}
]
};
echartBar.hideLoading();
echartBar.setOption(option1);
}
也可以写在一个js函数中,如:
var echartBar = echarts.init(document.getElementById("stackbar"));
echartBar.showLoading();
var echartPie = echarts.init(document.getElementById("pie"));
echartPie.showLoading();
$.ajax({
url: "getFVIData.do",
type: 'GET',
cache: false,
dataType: 'json',
success: function (data) {
var option1 = { ......
‘肆’ 一个页面如何存在多个JS点击一张图片后换成另一张
可以提个思路,给四个图片分别命名如:
<img id="img1" src="xxx"/><img id="img2" src="xxx"/><img id="img3" src="xxx"/><img id="img4" src="xxx"/>
再来四个button如
<input type="button" id="btn1"><input type="button" id="btn2"><input type="button" id="btn3"><input type="button" id="btn4">分别控制对应的图片
当某id的button被点击时,改变对应的图片路径,并把其他id的img的路径改成默认的
需要代码的话 我可以写jquery给你,js的好久不写了..
‘伍’ 如何用js获取表单中某个ID的值,加上另一个值,付给另外一个ID
可以用隐藏的,也可以自己用数组,map等一些对象保存
赋值的话可以通过id给它赋值document.getElementById("id").value= "alsdfj";
‘陆’ 想在一个div里面添加图片,用js怎么写啊
1、新建一个HTML文件,保存为test.html,用于编写代码实现拖放功能 。
‘柒’ 怎样用js插入多张图片
vararrImgs={"url1","url2","url3",...};图片地址存在数组中
varhtml='';
//遍历数组插入img标签到页面
for(vari=0;i<arrImgs.length;i++){
html+='<imgsrc="'+arrImgs[i]+'"/>';//创建img标签,图片地址赋值src
}
document.getElementById("要插入的容器id").innerHtml=html;