怎么用简单的函数来实现下面的一段jquery代码?跪求答案啊
<script>$(document).ready(function(){$(".table1").mouseover(function(){$("#pid1").css...
<script>
$(document).ready(function () {
$(".table1").mouseover(function () {
$("#pid1").css({ "color": "#FF9E01", "font-size:": "15px" });
$("#btn1").css("background", "#FF9E01");
});
$(".table1").mouseout(function () {
$("#pid1").css("color", "#656565");
$("#btn1").css("background", "#ffffff");
});
});
$(document).ready(function () {
$(".table2").mouseover(function () {
$("#pid2").css({ "color": "#FF9E01", "font-size:": "15px" });
$("#btn2").css("background", "#FF9E01");
});
$(".table2").mouseout(function () {
$("#pid2").css("color", "#656565");
$("#btn2").css("background", "#ffffff");
});
});
$(document).ready(function () {
$(".table3").mouseover(function () {
$("#pid3").css({ "color": "#FF9E01", "font-size:": "15px" });
$("#btn3").css("background", "#FF9E01");
});
$(".table3").mouseout(function () {
$("#pid3").css("color", "#656565");
$("#btn3").css("background", "#ffffff");
});
});
</script> 展开
$(document).ready(function () {
$(".table1").mouseover(function () {
$("#pid1").css({ "color": "#FF9E01", "font-size:": "15px" });
$("#btn1").css("background", "#FF9E01");
});
$(".table1").mouseout(function () {
$("#pid1").css("color", "#656565");
$("#btn1").css("background", "#ffffff");
});
});
$(document).ready(function () {
$(".table2").mouseover(function () {
$("#pid2").css({ "color": "#FF9E01", "font-size:": "15px" });
$("#btn2").css("background", "#FF9E01");
});
$(".table2").mouseout(function () {
$("#pid2").css("color", "#656565");
$("#btn2").css("background", "#ffffff");
});
});
$(document).ready(function () {
$(".table3").mouseover(function () {
$("#pid3").css({ "color": "#FF9E01", "font-size:": "15px" });
$("#btn3").css("background", "#FF9E01");
});
$(".table3").mouseout(function () {
$("#pid3").css("color", "#656565");
$("#btn3").css("background", "#ffffff");
});
});
</script> 展开
2个回答
展开全部
$(document).ready(function() {
$(new Array(3)).each(function(i, dom) {
var index = i + 1;
var pid = $("#pid" + index),
btn = $("#btn" + index);
$(".table" + index).mouseover(function() {
pid.css({
"color": "#FF9E01",
"font-size:": "15px"
});
btn.css("background", "#FF9E01");
}).mouseout(function() {
pid.css("color", "#656565");
btn.css("background", "#ffffff");
});
})
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询