$('#return').append('aaaaaaaaaa<br />') var div = $('<span class="pre_btn" title="编辑"><em class="btn_ico ico-1"> </em>编辑</span>') div.appendTo($('div')) $('#return').append($.trim(div.text())+'<br />') $('#return').append(div.text().replace(/\s/g,'').replace('\r','').replace(' ','')+'<br />') .append('aaaaaaaaaa<br />') //键盘事件要绑定在document上 $(document).on('keydown',function(){ //用keyCode 和 which 兼容不同浏览器 if(e.keyCode == 13 || e.which == 13){ // } }) //ie中无法执行,应该是document $(window).on('keydown',function(){}) //click事件依然存在,因为click是绑定在$('dom')上 $('dom').on('click','selecter',function(){ }) $('dom').empty(); //对象复制,key为数字 var a = {} a['3']=3; a['2']=2 a['4']=4 a Object {2: 2, 3: 3, 4: 4} var a = {} a['a3']=3; a['a2']=2 a['a4']=4 a Object {a3: 3, a2: 2, a4: 4} var a = {} a['a']=null a['3']=3; a['2']=2 a['4']=4 a Object {2: 2, 3: 3, 4: 4, a: null}