Friday, 15 April 2011

jquery - How to find current elements root div class? -



jquery - How to find current elements root div class? -

when clicked on checkbox , trying find root div class of element

i trying different options ,but of them getting undefined .

$(document).on("click", ".checkboxclas", function(e) { var cls = $(this).find('div:first').attr('class') ; alert(cls) });

when clicked on activateuihtml checkbox, wanted display activateuihtmlparentdivclass

when clicked on ordersdiv checkbox , wanted display parentsordersdivclass

http://jsfiddle.net/e56ty/31/

could please tell me how .

try utilize .parents().last() find lastly parent element, think have confusion root element is.

$(document).on("click", ".checkboxclas", function(e) { var cls = $(this).parents('div').last().attr('class') ; alert(cls); }); demo

jquery

No comments:

Post a Comment