使用以下动态生成的HTML:
<div class="widget widget_1">
<div class="widget_header widget_header_1"></div>
<div class="widget_sub_header widget_sub_header_1"></div>
<div class="widget_content widget_content_1"></div>
<div class="widget_footer widget_footer_1"></div>
<div>
<div class="widget widget_1">
<div class="widget_header widget_header_1"></div>
<div class="widget_sub_header widget_sub_header_1"></div>
<div class="widget_content widget_content_1"></div>
<div class="widget_footer widget_footer_1"></div>
<div>
<div class="widget widget_6">
<div class="widget_header widget_header_6"></div>
<div class="widget_sub_header widget_sub_header_6"></div>
<div class="widget_content widget_content_6"></div>
<div class="widget_footer widget_footer_6"></div>
<div>
我有以下脚本有效:
$("body").on({
mouseenter: function() {
console.log( "enter" );
},
mouseleave: function() {
console.log( "leave" );
}
}, ".widget_content");
我的问题是,如何在不影响其他.widget_content
的情况下替换.widget_content
悬停的文字?
答案 0 :(得分:1)
就这么简单
$(this).text('updated text');
OR
$(this).html('updated text');
答案 1 :(得分:0)
你应该更好地学习jquery而不是每五分钟询问一个新的/同一个问题。但是,这是一个片段:
$("body").on({
mouseenter: function() {
$(this).text("some new text");
},
mouseleave: function() {
console.log( "leave" );
}
}, ".widget_content");