Home > Web Front-end > JS Tutorial > Douban jquery code example_jquery

Douban jquery code example_jquery

WBOY
Release: 2016-05-16 19:03:49
Original
1095 people have browsed it

Method that will be executed after the document is loaded (see jquery documentation)
Generally speaking, all events should be bound when the document is loaded, but there is an exception.
For example, the content retrieved through the Ajax method also contains If it contains action buttons, you need to perform binding for this part of the function.

Copy the code The code is as follows:

//You need to manually call the load_event_monitor(element); method.
$(function() {
load_event_monitor(document);
});
//Note that the o object here is An html element rather than a jquery object, so the $(o) function should be used when calling its method
//Convert it into a jquery object.
Bowtech.init_forder = function(o) {
var eid = $(o).attr(“id“).split(“-“)[1];
var fo = $(“#f-“ eid);
var unfo = $( "#unf-" eid);

fo.click(function() {
$(o).hide();
unfo.show();
fo.hide( );
});
unfo.click(function() {
$(o).show();
fo.show();
unfo.hide();
});
}


jQuery.fn.extend({
set_caret: function(){
if(!$.browser.msie) return;
var initSetCaret = function(){this.caretPos = document.selection.createRange().duplicate()};
this.click(initSetCaret).select(initSetCaret).keyup(initSetCaret);
},
insert_caret:function(textFeildValue){
var textObj = this[0];
if(document.all && textObj.createTextRange && textObj.caretPos){
var caretPos=textObj.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length-1) == ” ? textFeildValue ” : textFeildValue;
} else if(textObj.setSelectionRange){
var rangeStart=textObj.selectionStart ;
var rangeEnd=textObj.selectionEnd;
var tempStr1=textObj.value.substring(0,rangeStart);
var tempStr2=textObj.value.substring(rangeEnd);
textObj.value= tempStr1 textFeildValue tempStr2;
textObj.focus();
var len=textFeildValue.length;
textObj.setSelectionRange(rangeStart len,rangeStart len);
textObj.blur();
} else {
textObj.value =textFeildValue;
}
}
})

It is relatively simple to use it at the front desk, just write like this:

Copy code The code is as follows:



You can put the title here



here are some main contents

Hello world


hahaha


This experiment was completed on Shaka’s Shenzhou notebook



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template