Javascript 在jquery中从父子关系中查找第三个父关系 第一分区的子女

Javascript 在jquery中从父子关系中查找第三个父关系 第一分区的子女,javascript,jquery,Javascript,Jquery,这里有一个输入错误:在jQuery中,可以使用单击方法将单击事件处理程序附加到jQuery对象。使用全局jQuery函数选择元素(通常是jQuery或$)。要选择具有特定类的元素,请在类前面添加 $(function(){ $('.one').click(function(){ $('.three').text('hey'); }); }); 首先,在代码中,您应该更正class=“two”的代码。要选择div,请使用jquery.on()事件处理程序 $('se

这里有一个输入错误:
在jQuery中,可以使用
单击
方法将
单击事件
处理程序附加到jQuery对象。使用全局jQuery函数选择元素(通常是
jQuery
$
)。要选择具有特定类的元素,请在类前面添加

$(function(){
    $('.one').click(function(){
      $('.three').text('hey');
    });
}); 

首先,在代码中,您应该更正
class=“two”
的代码。要选择div,请使用jquery
.on()
事件处理程序

$('selector')。在('click',callback())上

请参阅以下代码

$('.one').click(function(event) {
    // this function will be fired when the div with class `one` is clicked 

    var $three = $('.three');
    // $three is now a jQuery object representing the div 
    // DOM element with the class `three`

    // your code here     
}); 

我还创建了一个JSFIDLE:

在您的jquery代码中,
$(.three”)。在('click',function(){$(.one'}.doStuff})
上,您的jquery尝试在哪里?请阅读。
$('.one').click(function(event) {
    // this function will be fired when the div with class `one` is clicked 

    var $three = $('.three');
    // $three is now a jQuery object representing the div 
    // DOM element with the class `three`

    // your code here     
}); 
$('.one').on('click',function(){
  $('.three').addClass('changeColor');
})