Jquery查找父级元素
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>MyHtml.html</title><script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script><script type="text/javascript">$(document).ready(function () {var as = $("a");$.each(as, function(i, n){$(n).click(function(){if($(this).parent().attr("class")=="closed") $(this).parent().attr("class","opened");else$(this).parent().attr("class","closed"); }); });});</script></head><body><ul><li name="code">$("a").click(function(){ $(this).parent().attr("class","closed");)
?
3.
$("a").click(function(){ $(this).closest("li").removeClass("opened").addClass("closed"); });
4.
if ($(this).parent().first().attr("class") == "MyName") { temp = temp+"(Normal)"; } alert($("#show").attr("class").indexOf("b"));alert($("#show2").attr("class") == "myCls");alert($("div:eq(0)").attr("class") == "myCls"); <div id="show" name="code">1.attr(name)2.$(id)[index].className
?
?
?