jQuery 针对同一元素的多个函数操作的写法

xiaoxiao2021-02-28  91

jQuery 针对同一元素,如果同时需要对其进行多个函数的操作,开发时大可不必一个一个的写,可以采用串写的方式;

冗余方式: $("#mailpassword").click(function(){ $(this).val(""); $(this).val("").attr("type","password").css({"text-decoration":"none","color":'#666666','cursor':'text'}); $(this).val("").css({"text-decoration":"none","color":'#666666','cursor':'text'}); }); 建议方式: $("#mailpassword").click(function(){ $(this).val("").attr("type","password").css({"text-decoration":"none","color":'#666666','cursor':'text'}); });

转载请注明原文地址: https://www.6miu.com/read-34454.html

最新回复(0)