javascript - What kind of naming method is var $t?
给我你的怀抱
给我你的怀抱 2017-05-19 10:44:49
0
1
531

I found a piece of code on the Internet that was inserted under the cursor

    $.fn.extend({  
        insertContent : function(myValue, t) {  
            var $t = $(this)[0];  
            if (document.selection) {  
                this.focus();  
                var sel = document.selection.createRange();  
                sel.text = myValue;  
                this.focus();  
                sel.moveStart('character', -l);  
                var wee = sel.text.length;  
                if (arguments.length == 2) {  
                var l = $t.value.length;  
                sel.moveEnd("character", wee + t);  
                t <= 0 ? sel.moveStart("character", wee - 2 * t    - myValue.length) : sel.moveStart("character", wee - t - myValue.length);  
                sel.select();  
                }  
            } else if ($t.selectionStart || $t.selectionStart == '0') {  
                var startPos = $t.selectionStart;  
                var endPos = $t.selectionEnd;  
                var scrollTop = $t.scrollTop;  
                $t.value = $t.value.substring(0, startPos) + myValue + $t.value.substring(endPos,$t.value.length);  
                this.focus();  
                $t.selectionStart = startPos + myValue.length;  
                $t.selectionEnd = startPos + myValue.length;  
                $t.scrollTop = scrollTop;  
                if (arguments.length == 2) { 
                    $t.setSelectionRange(startPos - t,$t.selectionEnd + t);  
                    this.focus(); 
                }  
            } else {                              
                this.value += myValue;                              
                this.focus();  
            }  
        }  
    });

I kept reporting errors at the beginning, and then I changed it to function insertContent(myValue, t) {}
It turned out that var $t reported an error, and $t disappeared directly. I was nested in php. Logically speaking, php does not No analysis, but he just disappeared

给我你的怀抱
给我你的怀抱

reply all(1)
滿天的星座

PHP variable rules:
Variables start with a $ sign, followed by the name of the variable
Variable names must start with a letter or an underscore
Variable names cannot start with numbers
Variable names can only contain alphanumeric characters and underscores (A-z, 0- 9 and_)
Variable names are case-sensitive ($y and $Y are two different variables)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template