jquery checkbox 选中事件怎么写

jquery checkbox 选中事件怎么写,第1张

<input type="checkbox" id="checkbox1"/> $("#checkbox1").on("click", function(){

    if($(this).is(":checked")){

        //选中

    }else {

        //取消选中

    }

})

$(function

()

{

//除了表头(第一行)以外所有的行添加click事件.

$("tr").first().nextAll().click(function

()

{

//为点击的这一行切换样式bgRed里的代码:background-color:#FF0000

$(this).children().toggleClass("bgRed")

//判断td标记的背景颜色和body的背景颜色是否相同

if

($(this).children().css("background-color")

!=

$(document.body).css("background-color"))

{

//如果相同,CheckBox.checked=true

$(this).children().first().children().attr("checked",

true)

}

else

{

//如果不同,CheckBox.checked=false

$(this).children().first().children().attr("checked",

false)

}

})

})

以上这篇JQuery点击行tr实现checkBox选中的简单实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11655645.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-17
下一篇2023-05-17

发表评论

登录后才能评论

评论列表(0条)

    保存