How to get the value of custom HTML attribute using JQuery?

user8811

I have a repeater with check boxes in each row. I'm trying to check the check box in row based on another check box in same row. For this I'm executing a function on OnClick event of check box and this function finds the custom attribute of the parent and checks if parent is checked or not. If returned true it checks the check box with same attribute name for child class . Th problem is I can't get the value of custom attribute of parent class. It is always undefined.

childid in jquery function is always undefined. I tried using data property too but it's of no use .

$(objid).data('chldname');
function check_view(objid) {
    var childid = $(objid).attr('chldname');
    if ($(objid).is(':checked')) {
        $("[name=" + childid + "]").attr('checked', true);
    }
}

HTML:

<td style="text-align: center">
    <asp:checkbox id="cb_uploadaccess" runat="server" chldname='chld<%#Eval("ROLE_SEQ")%>' onclick='JavaScript:return check_view(this);' />
    <asp:hiddenfield id="hiddenuploadaccess" runat="server" value='<%#Eval("UPLOAD_ACCESS")%>' />

</td>
<td style="text-align: center">
    <asp:checkbox id="cb_viewaccess" name='chld<%#Eval("ROLE_SEQ")%>' runat="server" />
    <asp:hiddenfield id="hiddenviewaccess" runat="server" value='<%#Eval("VIEW_ACCESS")%>' />

</td>
user8811

I did this in another way, just changed my JQuery function like this which worked.

function check_view(objid)
            {
                var childid = $(objid).attr('ID');
                var childId1 = childid.substr(childid.length - 2);



                if ($(objid).is(':checked')) {

                        $(childId1).attr('checked', true);
                        $("[id$=chpMain_rptDocAccessroles_cb_viewaccess" + childId1 + "]").attr('checked', true);

                }

            }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Get value of a Custom Attribute using Javascript or Jquery

Get value of a custom attribute with jquery

How to get the value of data attribute using jquery

How to get data attribute value using jquery

How to get to attribute value using jquery

To get Custom attribute value present in <ul> tag using jquery

Get custom attribute value from multiple select option using Jquery

How to get the value of input field by custom attribute in jquery

How to verify if a certain value is present in a custom attribute using javascript or jquery?

Get value from custom html attribute

how to get selected attribute value in datalist using jQuery

How can I get the attribute value with a condition using jquery?

How to get the Image "title" attribute value into another element using jQuery

How do I get the class attribute value using jquery and javascript

How to get previous tag (td) child attribute value using jquery?

How to get the value of a single attribute from a HTML tag using Beautifulsoup?

Get custom attribute value using LINQ to XML

Jquery How to read custom attribute value

How to change HTML custom attribute value by JavaScript?

How to get value of custom data attribute in ionic?

Unable to get value of data attribute using jQuery

Not able to get the value of xml attribute using jquery

Get custom attribute value

Get a custom attribute with jQuery

How to get a custom attribute on enum by passing in the enum value and attribute type?

jQuery: how to return the 'value' of an html attribute

how to get value of data attribute and use it in jquery?

How to get a value of data-attribute with jquery

How to get attribute value from HTML tags