jQuery/parent()

解説 指定した要素の親要素を選択
sample1

sample1p

sample1code
$(function(){
  $("#sample1p").click(function(){
	$(this).parent().css("background","red");
  });
});
sample2
  • 1-1
  • 1-2
    • 1-2-1
    • 1-2-2
  • 1-3
sample2code
$(function(){
  $("#element1").click(function(){
  	$(this).parent().css("color","red");
  });
  $("#element2").click(function(){
  	$(this).parent().css("color","pink");
  });  
});