JSFiddle - React, Tailwind, and code Playground

by Rex Chen

HTML

<button id="b1">A</button>
<button id="b2">B</button>
<p></p>
<img width="64" height="64" id="im1"/>

JavaScript

//模块运行状态池
var uiButton_0_1ON = true;
var uiSetImg_0_1ON = false;
var uiButton_1_1ON = true;
var uiSetImg_1_1ON = false;

//变量池
var LocalParameter_0 = "b1";
var LocalParameter_1 = "im1";
var LocalParameter_2 = "http://sandbox.runjs.cn/uploads/rs/244/f1gv147l/monster.png";
var LocalParameter_3 = "b2";
var LocalParameter_4 = "";
var LocalParameter_5 = "http://sandbox.runjs.cn/uploads/rs/244/f1gv147l/hero.png";

//按钮模块的状态值
var uiButton_0_1ON_state = 0;
var uiButton_1_1ON_state = 0;

//主进程
function check(){
if (uiButton_0_1ON){ 
    //监听鼠标事件
	$( "#" +LocalParameter_0 ).mousedown(function(){
		uiButton_0_1ON_state = 1;
	});
	$( "#" +LocalParameter_0  ).mouseup(function(){
		uiButton_0_1ON_state = 0;
	});

	if (uiButton_0_1ON_state){
        //Press状态
		uiSetImg_0_1ON = true;

	}else{
        //Relase状态
		
	}
}
if (uiSetImg_0_1ON){ 
    //调用jQuery设置图片的来源
	$("#" +LocalParameter_1).attr("src", LocalParameter_2);

    //自我销毁
	uiSetImg_0_1ON = false;
	
}
if (uiButton_1_1ON){ 

	$( "#" +LocalParameter_3 ).mousedown(function(){
		uiButton_1_1ON_state = 1;
	});
	$( "#" +LocalParameter_3  ).mouseup(function(){
		uiButton_1_1ON_state = 0;
	});

	if (uiButton_1_1ON_state){
		uiSetImg_1_1ON = true;

	}else{
		
	}
}
if (uiSetImg_1_1ON){ 
	$("#" +LocalParameter_1).attr("src", LocalParameter_5);

	uiSetImg_1_1ON = false;
	
}
}

//设置刷新率(程序运行周期)
window.setInterval("check()",20);