我將在一個頁面上有多個summernote字段,並且我想要一個動態的方式來獲取元素ID在做onblur時。我似乎無法得到的元素ID,它只是回來不確定獲取Summernote元素的ID
例HTML
<div class="summernote" id="desc_long" name="Long Description">Test 123</div>
的Javascript
$(function() {
$('.summernote').summernote({
toolbar: [
['headline', ['style']],
['style', ['bold', 'italic', 'underline', 'clear']],
['color', ['color']],
['font', ['strikethrough', 'superscript', 'subscript']],
['alignment', ['ul', 'ol', 'paragraph']],
['insert', ['link']],
],
onblur: function() {
var objid = $(this).attr("id");
alert(objid);
}
});
});
我認爲這裏是全局對象 – Geeky
通過event.target訪問id – Geeky
試着在控制檯上打印這個,看看哪個對象變得模糊。的console.log($(本)); –