页面
在输入框中填写你猜的答案,点击“显示答案”按钮,显示正确答案。
页面代码
function showAnswer(element){var elem=$(element);elem.next().show();}
//# // 初始化DataGrid对象
$('#dataGrid').dataGrid({searchForm: $('#searchForm'),columnModel: [{header:'${text("歇后语")}', name:'slangText', index:'a.slang_text', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){return '<a href="${ctx}/slang/slang/form?slangId='+row.slangId+'" class="btnList" data-title="${text("编辑歇后语")}">'+(val||row.id)+'</a>';}},{header:'${text("填写")}', name:'slangAnswer', index:'a.slang_answer', width:150, align:"left", formatter: function(val, obj, row, act){return '<input type="text">';}},{header:'${text("答案")}', name:'slangAnswer', index:'a.slang_answer', width:150, align:"left", formatter: function(val, obj, row, act){return '<button οnclick="showAnswer(this)">显示答案</button> <span style="display: none">'+row.slangAnswer+'</span>';}},{header:'${text("操作")}', name:'actions', width:120, formatter: function(val, obj, row, act){var actions = [];//# if(hasPermi('slang:slang:edit')){actions.push('<a href="${ctx}/slang/slang/form?slangId='+row.slangId+'" class="btnList" title="${text("编辑歇后语")}"><i class="fa fa-pencil"></i></a> ');actions.push('<a href="${ctx}/slang/slang/delete?slangId='+row.slangId+'" class="btnList" title="${text("删除歇后语")}" data-confirm="${text("确认要删除该歇后语吗?")}"><i class="fa fa-trash-o"></i></a> ');//# }return actions.join('');}}],//# // 加载成功后执行事件ajaxSuccess: function(data){}
});
数据表
CREATE TABLE `slang` (`slang_id` int NOT NULL AUTO_INCREMENT COMMENT '编号',`slang_text` text COLLATE utf8mb4_unicode_ci COMMENT '歇后语',`slang_answer` text COLLATE utf8mb4_unicode_ci COMMENT '答案',PRIMARY KEY (`slang_id`)
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='歇后语';
INSERT INTO `slang` VALUES (1,'老太太吃黄连','苦口婆心'),(2,'八十老翁练琵琶','老生常谈'),(3,'八十岁老汉学吹打','上气不接下气'),(4,'外甥打灯笼','照旧'),(5,'关公喝酒','不怕脸红'),(6,'矮子穿长袍','拖拖拉拉'),(7,'张飞绣花','粗中有细'),(8,'下雪天穿裙子','美丽动人'),(9,'孔夫子搬家','尽是输'),(10,'飞机上挂暖瓶','高水平'),(11,'西瓜皮打鞋掌','开溜'),(12,'挨鞭子不挨棍子','吃软不吃硬'),(13,'黄连做笛子','苦中作乐'),(14,'芝麻开花','节节高'),(15,'中秋节赏桂花','花好月圆'),(16,'炒菜的勺子','尝尽了酸甜苦辣'),(17,'书呆子的背包','净是文章'),(18,'孔夫子唱戏','出口成章'),(19,'老鼠爬进书包里','咬文嚼字'),(20,'王婆卖瓜','自卖自夸'),(21,'小肚子搁暖壶','热心肠'),(22,'狗咬吕洞宾','不识好人心'),(23,'姜太公钓鱼','愿者上钩'),(24,'独臂将军','有一手'),(25,'铁匠铺的买卖','样样都得过硬'),(26,'春天的竹笋','天天向上'),(27,'夏天的雨','说来就来'),(28,'秋后的扇子','没人过问'),(29,'冬天吃葡萄','寒酸'),(30,'水中捞月','一场空'),(31,'大风天吃炒面','不好张口'),(32,'冰山上画画','好景不长'),(33,'沙滩上散步','一步一个脚印');