答案 0 :(得分:1)
希望各个彩色块的类别为red_block
和yellow_block
setInterval(function(){
var reds = document.getElementByClassName('red_block')
var yellows = document.getElementByClassName('yellow_block')
if(reds.length == yellows.length){
alert("what ever")
}
}, 1);
document.getElementByClassName
将返回具有该类
将时间间隔设为1ms,以便每时每刻检查值
答案 1 :(得分:0)
我已经包含了以下示例。
json

library(httr)
pc_json <- list(
postcodes = c("PR3 0SG", "M45 6GN", "EX165BL")
)
res <- POST("https://api.postcodes.io/postcodes"
, body = pc_json
, encode = "json")
appData <- content(res)
&#13;
$(document).ready(function () {
var color = "White";
$("#btnWhite").click(function () {
color = "#FFFFFF"
});
$("#btnYellow").click(function () {
color = "#FFFF00"
});
$("#btnRed").click(function () {
color = "#FF0000"
});
$("#btnBlue").click(function () {
color = "#0070C0"
});
$("#btnGreen").click(function () {
color = "#00FF00"
});
$("table tr td").click(function () {
$(this).css("background-color", color);
});
});
&#13;