本文介绍了点击第二个按钮,我想要第一个和第二个按钮变色。我可以这样做吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 在这里,我有3个字段,如温度,浊度,人数。 对于温度字段 - 我已经创建了四个按钮,我想要第一个按钮上的onclick功能,我想要第一个按钮在会话变量中得到彩色和存储值'1'。类似地点击第二个按钮,我希望第一个,第二个按钮在会话变量中变为n存储值'2'。点击第3个按钮,我想要第1个,第2个,第3个按钮在会话变量中显示颜色n存储值3。单击第4个按钮,我希望所有按钮在会话变量中变为颜色n存储值4。我希望在我的php文件中使用此会话变量进行进一步计算。 同样我想要的是我的湿度以及人数。我可以这样做吗???任何形式的帮助都会有用!! 我尝试过的事情: <!DOCTYPE html> .button { 背景颜色:白色; 边框:1px纯黑色; 颜色:白色; 填充:8px 30px; text-align:center; text-decoration:none; display:inline-block; 光标:指针; 浮动:左; }here, i have 3 fields like temperature,humdity,Number of people.For Temperature field-i have created four buttons,i want the functionality like onclick on 1st button,i want 1st button to be get colored and as well as store value '1' in session variable.similarly onclick on 2nd button,i want 1st,2nd buttons get coloured n store value '2' in session variable .Onclick on 3rd button,i want 1st,2nd,3rd buttons get coloured n store value '3' in session variable .onclick on 4th button,i want all buttons get coloured n store value '4' in session variable.i want this session variable in my php file for further calculation.same i want for my Humidity as well as Number of people field.how can i do it??? any kind of help will be useful!!What I have tried:<!DOCTYPE html>.button { background-color: white; border: 1px solid black; color: white; padding: 8px 30px; text-align: center; text-decoration: none; display: inline-block; cursor: pointer; float:left;}温度湿度人数推荐答案你好 我不确定你是不是这样,但我在这里尝试了一个codepen: [ code pen ]helloi'm not sure if it's what you excepted but i tried a codepen here :[code pen]<html> temp <button data-tp='temp' data-idx='1' class='bts'>1</button> <button data-tp='temp' data-idx='2' class='bts'>2</button> <button data-tp='temp' data-idx='3' class='bts'>3</button> <button data-tp='temp' data-idx='4' class='bts'>4</button> <input data-tp='temp' class='lastBtIdx'></input> hum <button data-tp='hum' data-idx='1' class='bts'>1</button> <button data-tp='hum'data-idx='2' class='bts'>2</button> <button data-tp='hum'data-idx='3' class='bts'>3</button> <button data-tp='hum' data-idx='4' class='bts'>4</button> <input data-tp='hum' class='lastBtIdx'></input></html> js:js:(' 。bts')。click( function ( i,e){ thistype =('.bts').click(function(i,e){ thistype =( this )。data(' tp');(this).data('tp'); 这篇关于点击第二个按钮,我想要第一个和第二个按钮变色。我可以这样做吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-29 12:22