Posts

javascript - Jquery .text().length counting element's code as well as characters? -

i want detect amount of characters in div , if there less five: var n = $("#mydiv").text().length; if (n < 5){ //do } but 'n' seems counting code used div self: <div id="mydiv"> </div> so if there no characters within div: n = 23 . does know way adjust count characters within div itself? trim text exclude leading , trailing spaces in text var n = $.trim($("#mydiv").text()).length; //use string.trim() if want support ie9+ demo: fiddle $.trim() string.trim()

javascript - How To Value Copy and Paste in another Textbox from Dropdown -

Image
hi guys can tell me how copy field value field when use check box in dropdown have click check box value copy in textbox. when have select checkbox value move in textbox auto. i using multiselect dropdwon list , need when select checkbox value option 1 or 2 value move in textbox automatic in below text box. <script language="javascript"> $(document).ready(function() { $("#dropdown").on('change',function(){ var dropdownval=this.value; $("#textbox").val(dropdownval); }); }); </script> </head> <body onload="prettyprint();"> <form> <p> <select multiple="multiple" name="dropdown" style="width:370px"> <option value="red">red</option> <option value="green">green</option> <option value="blue">blue</option> <option valu...

C++ copy constructor, destructor error and more -

i new c++. have tried figure out how copy constructor works , destructor, cant work wright. i 2 errors: error: expected primary-expression before ';' token delete []; i have tried put different things after delete [] none of them worked, left blank @ moment. class dynamicline has no member named 'p2', what doing wrong? did decleare p2 in test program. this header file: template<class t> class dline { public: dline (t *v1, t *v2) : v1 {v1}, v2 {v2} {} t* v1; t* v2; // copy constructor dline(const dline &l) { v1 = l.v1; v2 = l.v2; } dline& operator= (const dline &l) { if (this == &l) { return *this; } v1 = l.v1; v2 = l.v2; return *this; } ~dline() { delete []; } }; i have vector class: using namespace std; vector2::vector2(float nx, float ny) : x {nx} , y {ny} { } float vector2::distancefrom(vector2 v) { return sqrt( (x - v.x)*(x - v.x) + (y - v.y)*(y - v.y) ); } os...

java tells that can not find symbol -

i studying core java myself. wrote java program, , got 1 error: ...cannot find symbol "refc" but is declared object reference... can explain that? import java.io.*; class contactmain { int count = 0; int[] = new int[5]; contactmain() { system.out.println("a"); a[count] = count+1; count++; } } class contact { public static void main(string args[]) { int y = 0; int = 0; while (i<10) { contactmain refc = new contactmain();//create instance of class i++; } system.out.println(refc.a[i]); } } in last statement, got error {refc.a[i]} cannot find symbol. please, me. scope matters, you're declaring variable inside while(..){ } , trying access outside of loop, change code to: while(i<10) { contactmain refc=new contactmain(); i++; system.out.println(refc.a[i]); }

ruby on rails - Path helper inserts plus sign instead of space -

i want have link_to with <%= link_to "my link", search_path(par: "my link") %> but gets rendered <a href="/search?par=my+link">my link</a> instead of <a href="/search?par=my link">my link</a> is there way force behave properly, , not manually insert %20 instead of space? try this require 'cgi' cgi.unescape "/search?par=my+link" example: 1.9.3p448 :006 > cgi.unescape "/search?par=my+link" => "/search?par=my link" 1.9.3p448 :007 > cgi.unescape "/search?par=my%20link" => "/search?par=my link" hope helps!

html - Strange behavior of inline-block elements inside absolute positioned parent -

i have few <div> s having display:inline-block , inside absolute positioned parent <div> . html <div id='wrap'> <div id='container'> <div class='box'></div> <div class='box'></div> <div class='box'>&#64;</div> <div class='box'></div> </div> </div> css *{ margin:0; } html, body{ height:100%; } #wrap{ position:relative; background:lightgreen; height:100%; } #container{ position:absolute; bottom:0px; vertical-align:baseline; } .box{ display:inline-block; width:80px; height:120px; background:white; border:1px solid; } when add ascii character codes in of <div> s, strangely other <div> s move up. if remove ascii character <div> s align in same row. check jsfiddle i aware of other ways making layout, can make boxes absolute , force them positioned @ bottom of parent, i'm aware of css...

Use of "("?) in Lua with string.find and the value that it returns -

a, i, c = string.find(s, '"("?)', + 1) what role of ? here? believe checking double quotes not understand use of "("?) . i read string.find returns starting , ending index of matched pattern. per above line of code, a , i , c , 3 values being returned. third value being returned here? ? matches optional character, i.e, 0 or 1 occurrence of character. pattern "("?) matches " , followed optional " , i.e, matches either " or "" . note match "? (zero or 1 " ) captured. as return value of string.find() , string.find() : if pattern has captures, in successful match captured values returned, after 2 indices. the capture third return value, when there successful match.