UNPKG

zoomla

Version:

16年专业研发|中文alexa排名第一的CMS品牌-基于dotNET core、功能强大,集成站群、微信开发、小程序与ERP及OA办公系统,支持国际语言和多民族语言,世界五百强与大型门户专用高端网站内核CMS系统

41 lines 1.29 kB
//用于无障碍浏览--阅读 var ZLSounder = {}; ZLSounder.Init = function (filter) { var ref = this; //if (!filter) { filter = "a,input[type=button],.need_sounder"; } console.log($(filter).length); $(filter).mouseover(function () { var text = ref.GetTextFromDom(this); if (text != "") { ref.PlayText(text) } }); } ZLSounder.sounder = $('<video autoplay="autoplay" style="display:none;"></video>'); ZLSounder.GetTextFromDom = function (obj) { var text = ""; var $obj = $(obj); if ($obj.data("sounder")) { text = $obj.data("sounder"); return text; } switch (obj.tagName) {//大写 case "INPUT": text = $(obj).val(); break; default: text = $(obj).text(); break; } return text; } ZLSounder.PlayText = function (text) { var ref = this; $.post("/API/Sounder", { tex: text }, function (data) { ref.sounder.attr("src", data); ref.sounder[0].play(); }) } $(function () { ZLSounder.Init("a,input[type=button],button,.sounder"); }) //1,根据样式筛选 //2,目标tag上可加 data-sounder="需要阅读的语句" //3,建议放在底部,避免其他动态元素未加载完便执行