开发者

how to find check box id in javascript

开发者 https://www.devze.com 2023-01-31 05:33 出处:网络
how to find check box idand use the :checked selector to determine if it is checked in javascript.i am not getting checkbox id in javascr开发者_StackOverflowiptMy favorite method is to create a javasc

how to find check box id and use the :checked selector to determine if it is checked in javascript.i am not getting checkbox id in javascr开发者_StackOverflowipt


My favorite method is to create a javascript variable and put the checkbox's ClientID into it:

<script language="javascript">

    var myCheckBox = '<%= myCheckBox.ClientID %>';

</script>

Then somewhere else you can just use that variable to find the control you want. This way even if you end up changing the actual ID of the object in question, the ClientID will automatically update and you won't have to update your javascript that matches it:

document.getElementById(myCheckBox);
0

精彩评论

暂无评论...
验证码 换一张
取 消