当前位置: 首页 > 编程语言

js改变class,写一个根据屏幕分辨率大小改变网页大小的JS脚本

 时间:2020-04-15 09:33:45 来源: 

JS改变TD的高度,可以随意拉伸

给个例复子。制<table border="1"><tr><td id="tdname">test</td></tr><tr><td><input type="button" value="增加百" onclick="changetdheight()"</td></tr></table><script language="javascript">function changetdheight(){度var obj=document.getElementById("tdname");var h=obj.offsetHeight;var kh=h+100;obj.style.height=kh+"px";}</script>本回答被提问者和网友采纳

html怎么用函数改变文本域中北景颜色

js或者jquery 在script中设置事件,判断条件,通过$("#id").css("background-color","red");

用java画一元二次方程的图形,a、b、c用三个滑竿JSlider改变值,具体见下图

按照你的要求编写的Java程序如e5a48de588b6e799bee5baa6e79fa5e9819331333361303666下:importjava.awt.BorderLayout;importjava.awt.Color;importjava.awt.Component;importjava.awt.Container;importjava.awt.Graphics;importjava.awt.GridLayout;importjava.util.ArrayList;importjava.util.Dictionary;importjava.util.Hashtable;importjava.util.List;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JPanel;importjavax.swing.JSlider;importjavax.swing.event.ChangeEvent;importjavax.swing.event.ChangeListener;publicclassKKKextendsJFrameimplementsChangeListener{Containercon;JLabeljl1=newJLabel("avalue");JLabeljl2=newJLabel("bvalue");JLabeljl3=newJLabel("cvalue");JPaneljp=newJPanel();JPaneljp1=newJPanel();JPaneljp2=newJPanel();JPaneljp3=newJPanel();JCurvePaneljcp=newJCurvePanel();JSliderjs1=newJSlider(JSlider.HORIZONTAL,0,100,50);JSliderjs2=newJSlider(JSlider.HORIZONTAL,0,100,50);JSliderjs3=newJSlider(JSlider.HORIZONTAL,0,100,50);inta=1;intb=2;intc=1;KKK(){js1.setPaintTicks(true);js1.setMinorTickSpacing(5);js1.setMajorTickSpacing(100);js1.setPaintLabels(true);Dictionary<Integer,Component>labels=newHashtable<Integer,Component>();labels.put(0,newJLabel("0"));labels.put(20,newJLabel("20"));labels.put(40,newJLabel("40"));labels.put(60,newJLabel("60"));labels.put(80,newJLabel("80"));labels.put(100,newJLabel("100"));js1.setLabelTable(labels);js2.setPaintTicks(true);js2.setMinorTickSpacing(5);js2.setMajorTickSpacing(100);js2.setPaintLabels(true);js2.setLabelTable(labels);js3.setPaintTicks(true);js3.setMinorTickSpacing(5);js3.setMajorTickSpacing(100);js3.setPaintLabels(true);js3.setLabelTable(labels);js1.addChangeListener(this);js2.addChangeListener(this);js3.addChangeListener(this);jp.setLayout(newGridLayout(3,1));jp1.add(js1);jp1.add(jl1);jp2.add(js2);jp2.add(jl2);jp3.add(js3);jp3.add(jl3);jp.add(jp1);jp.add(jp2);jp.add(jp3);con=getContentPane();jp.setBackground(Color.WHITE);con.add(jp,BorderLayout.EAST);con.add(jcp,BorderLayout.CENTER);setSize(700,500);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setLocationRelativeTo(null);setVisible(true);}publicstaticvoidmain(String[]args){newKKK();}@OverridepublicvoidstateChanged(ChangeEventce){if(ce.getSource()==js1){a=js1.getValue();}if(ce.getSource()==js2){b=js2.getValue();}if(ce.getSource()==js3){c=js3.getValue();}repaint();}classJCurvePanelextendsJPanel{JCurvePanel(){this.setBackground(Color.BLACK);this.setForeground(Color.WHITE);}publicvoidpaint(Graphicsg){super.paint(g);intx0,y0;x0=this.getWidth()/2;y0=this.getHeight()/2;inttriangleYX[]={x0-5,x0+5,x0};inttriangleYY[]={50,50,45};g.setColor(Color.WHITE);g.drawLine(x0,50,x0,y0*2-50);g.fillPolygon(triangleYX,triangleYY,3);for(inti=y0;i>50;i-=10){g.drawLine(x0,i,x0+5,i);}for(inti=y0;i<y0*2-50;i+=10){g.drawLine(x0,i,x0+5,i);}inttriangleXX[]={x0*2-50,x0*2-50,x0*2-45};inttriangleXY[]={y0-5,y0+5,y0};g.drawLine(50,y0,x0*2-50,y0);g.fillPolygon(triangleXX,triangleXY,3);for(inti=x0;i>50;i-=10){g.drawLine(i,y0,i,y0-5);}for(inti=x0;i<x0*2-50;i+=10){g.drawLine(i,y0,i,y0-5);}List<Integer>listx=newArrayList<Integer>();List<Integer>listy=newArrayList<Integer>();for(intj=-200;j<200;j++){listx.add(j);listy.add(-(a*j*j+b*j+c));}for(inti=0;i<listx.size()-1;i++){g.drawLine(listx.get(i)+x0,listy.get(i)+y0,listx.get(i+1)+x0,listy.get(i+1)+y0);}}}}运行结果:

php如何设置规定时间改变字体颜色?

网页吗抄?这是js干的事袭情,使用百js定时器。setInterval("setColor()",1000);function setColor(){ // 定义颜度色数组 var arr = ['#fff' , '#000'];var index = Math.floor((Math.random()*arr.length)); // 更改知颜色 document.getElementById('要切换字体的道ID').style.color = arr[index]}

js怎么阻止冒泡事件 让子元素不改变父元素

input.onclick=function(ev){ var e=window.event |度| ev; if(e.stopPropagation){ e.stopPropagation(); }else{ e.cancelBubble=true; }}