Method To be executed after the document is loaded (see the jquery document)
Generally, all events should be bound during document loading, but there is one exception.
For example, if the content retrieved through the Ajax method also contains action buttons, you need to bind these functions.
Copy codeThe Code is as follows:
// Call load_event_monitor (element) manually.
$ (Function (){
Load_event_monitor (document );
});
// Note that the o object here is an html element rather than a jquery object, so you should use the $ (o) function when calling its method.
// Convert it to 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;
}
}
})
The front-end is easy to use. You only need to write it like this:
Copy codeThe Code is as follows:
<Div id = "test2" class = "mod">
<H3>
The title can be set here.
</H3>
<Div class = "j modb a_forder" id = "modb-1002">
Here are some main contents
<Dl>
<Dt> Hello world </dt>
<Dd>
Hahaha </dd>
</Dl>
This experiment was completed in shenzhouben of shujia.
</Div>
<Div class = "edit">
<A id = "f-1002" class = "forder" href = "javascript: void (0);"> [collapse] </a> <a id = "unf-1002 ″
Class = "unforder" href = "javascript: void (0);"> [Expand] </a>
</Div>
</Div>
The style is omitted. You can write it by yourself and then send two messages:
Collapsed