lang stringclasses 4
values | desc stringlengths 2 8.98k | code stringlengths 7 36.2k | title stringlengths 12 162 |
|---|---|---|---|
JS | Component child in React.jsI am creating an app which can be seen as a crypto-portfolio list . Every coin item has some details like holdings and price . These are saved in a dictionary saved in localstorage and loaded in the portfolio container components ' state . The hierarchy can be seen as Container > PortfolioLis... | export default class PortfolioContainer extends React.Component { constructor ( props ) { super ( props ) ; this.state = ( { portfolio : { ICX : { transactions : [ { purchase : ' $ 49.99 ' , amount : 50 } ] , price : { raw : { BTC : { PRICE:3.20 } } , display : { BTC : { PRICE:3.20 } } } } , currency : 'BTC ' , total :... | React.js Component Child - Global interaction |
JS | i do n't know how the code : const countFrom = x = > ( ) = > ( x++ , x ) ; from here , works : | const countFrom = x = > ( ) = > ( x++ , x ) ; let a = countFrom ( 1 ) console.log ( 'output : ' , a ( ) ) // output : 2console.log ( 'output : ' , a ( ) ) // output : 3console.log ( 'output : ' , a ( ) ) // output : 4console.log ( 'output : ' , a ( ) ) // output : 5 .as-console-wrapper { min-height : 100 % ! important ... | java-script arrow function returns ( x++ , x ) |
JS | When runningit gives a value of 9658921879781124 , which is less than the original value . Why is this the case ? | console.log ( parseInt ( `` 9658921879781125 '' ) ) | JavaScript parseInt conversion is buggy |
JS | Recently , i wrote some code for filtering bad words in a string . And a tons of words are going to be filtered . My code works but the performance is not really well as expected.Below code is only the demo : Method 1 : Method 2 : I had also make the performance test with jsperf which comparing with split & join or rep... | let list = [ `` omg '' , `` bbq '' , `` wth '' , `` hello '' , `` world '' ] ; let smallString = `` wthhello123456worldomg789bbqomgomg '' ; for ( let i = 0 ; i < list.length ; i++ ) { smallString = smallString.replace ( new RegExp ( list [ i ] , `` g '' ) , `` *** '' ) ; } let list = [ `` omg '' , `` bbq '' , `` wth ''... | How to replace a ton of words in a string with better performance ? |
JS | we are using below script to display results for both types : admin & designerscriptnow we want to display `` Designer '' column only for type = admin so we are trying to display javascript result with php if condition as mentioned herephpbut its displaying like below image . this code is reason for displaying below im... | var colsOption = [ { id : 'entity_id ' , header : `` Order Id '' , width : '' 15 '' , renderer : my_renderId } , { id : 'created_at ' , header : `` Order Date '' , width : '' 120 '' } , { id : 'entity_id ' , header : `` Order Id '' , width : '' 75 '' } , { id : 'product_id ' , header : `` Product Id '' , width : '' 70 ... | display javascript result with php if condition |
JS | I have applied the infinite-ajax-scroll to my project . It is a PHP Laravel project that displays a long list of divs . Instead of using pagination , I wanted to make the user see all results on the same page by scrolling down . I also have a filter for the results and it works well , but the strange thing is that afte... | // Search functions function storeSearchAjax ( ) { var filters = searchFilters ( ) ; $ .ajax ( { method : 'get ' , data : filters , url : '/restaurants/search-ajax ' , success : function ( data ) { $ ( ' # result ' ) .html ( data ) ; } } ) ; } function searchFilters ( ) { offerFilter = $ ( `` .offerCheckbox : checked '... | PHP and jquery Ajax and infinite scroll for filtering |
JS | I want to add a string to a text area which has value may be grater than 2 lines . May be it is an ASCII ART but my main question is that how can I post ASCII art to a textarea ? I am using jQuery and following codes : If I am using specific button means contain a class than what will be the code.But it does not show m... | < script src= '' https : //ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js '' > < /script > < script > $ ( document ) .ready ( function ( ) { $ ( `` button '' ) .click ( function ( ) { $ ( `` input : text '' ) .val ( `` ( ██ ) __________ ( █ ) _______________██████_________ ( ███ ) ___________ █████████______... | add a string to a textarea using jQuery |
JS | In this case I 'm using two parallel arrays ( cost [ ] and scores [ ] ) both of these with data on them that is parallel to each other.This code is correct as am copying it from the book I 'm using . What i do n't get is how can this for loop work for the costs array . I get we are passing both arrays as parameters in ... | function getMostCostEffectiveSolution ( scores , costs , highScore ) var cost = 100 ; var index ; for ( var i = 0 ; i < scores.length ; i++ ) { if ( scores [ i ] == highScore ) { if ( cost > cost [ i ] ) { index = i ; cost = cost [ i ] ; } } } return index ; } | How can a single for loop iterate over multiple arrays ? |
JS | My select box puts a dotted rectangle , when i do mouse select in it . How can i clear this ? I saw many people having this same issue , and taking their inputs , i updated my css with these properties , but of no use.I am using Firefox 38.0 on Ubuntu 14.04 | select : :-moz-focus-inner { border : 0 ; outline : 0 ; } select { color : # 000 ; color : rgba ( 0,0,0,0 ) ; text-shadow : 0 0 0 # 000 ; margin : 10em 10em ; } select : :-moz-focusring { color : transparent ; text-shadow : 0 0 0 # 000 ; } | Select box puts dotted rectangle on mouse select |
JS | I have a js object that looks like this : I want to access the property listed under the nested object `` ocd-division/country : us '' ( aka `` name '' ) , but the problem I 'm having is that `` ocd-division/country '' is a variable object . Like it might be `` : can '' for Canada or something . My question is , can I ... | var object = { `` divisions '' : { `` ocd-division/country : us '' : { `` name '' : `` United States '' , } } } ; var country = document.getElementById ( `` p '' ) ; p.innerHTML = object.divisions [ `` ocd-division/country : us '' ] .name ; | Accessing properties of a variable object with JavaScript |
JS | I am using John Pollocks `` A beginners guide to javascript edition 3 . `` The lesson I am doing is 4-2 which can be found here : http : //www.cs.tufts.edu/es/93IDI/refs/Pollock-3rd.pdf the page number for the PDF is 107 ( actual page number 83/84 ) . Correct me if I am wrong but the instructions say to print `` Hi the... | function two_strings ( text1 , text2 ) { var added_text=text1+ `` `` +text2 ; return added_text ; } function result ( ) { var get_result=two_strings ( `` Hi '' , '' there ! `` ) ; document.write ( get_result ) ; } var ff_result = two_strings ( `` regular '' , '' text '' ) ; window.alert ( ff_result ) ; result ( ) ; < !... | Is my code right , and is the book I am using wrong ? |
JS | I 'm looking for help in understanding this line of code in the npm moudle hash-index.The purpose of this module is to be a function which returns the sha-1 hash of an input mod by the second argument you pass.The specific function in this module that I do n't understand is this one that takes a Buffer as input and ret... | var toNumber = function ( buf ) { return buf.readUInt16BE ( 0 ) * 0xffffffff + buf.readUInt32BE ( 2 ) } | Buffer to integer . Having trouble understanding this line of code |
JS | I have two divs : One is the background that contains clickable items , and the second is an overlay div that is scrollable . I would like to be able to click the items in the first div without turning off the scrolling capability of the second div.Here is an example fiddle : https : //jsfiddle.net/samlalani/yu832xad/3... | < div id= '' wrapper '' > < table > < tr > < td onclick= '' alert ( ' 1 ' ) '' class= '' red '' > 111111 < /td > < /tr > < tr > < td > 2 < /td > < /tr > < tr > < td onclick= '' alert ( ' 3 ' ) '' class= '' red '' > 333333 < /td > < /tr > < tr > < td > 4 < /td > < /tr > < tr > < td > 5 < /td > < /tr > < tr > < td onclic... | Send click to background div |
JS | The code : It 's from p. 367 of JavaScript : The Definitive Guide , 6th ed.Here 's what I think is happening in this code.The variable content is being assigned the result of a .map ( ) call on the NodeList of paragraph tags returned by document.getElementsByTagName ( `` p '' ) . The .map ( ) method is accessed from th... | var content = Array.prototype.map.call ( document.getElementsByTagName ( `` p '' ) , function ( e ) { return e.innerHTML ; } ) ; | Do I understand this Function.prototype.call ( ) code correctly ? |
JS | Alright , so I made a pretty simple Tic-Tac-Toe game in Python at one point , and it was pretty fun , so I thought I 'd spice it up and do it in HTML/JS/CSS to make it a little bit more pretty . It was going pretty good , however I hit a little bump in the road when making the easy `` AI '' for the game . The easy AI f... | function computerEasyModeMove ( ) { if ( player == ' x ' ) { computer = ' o ' ; } if ( player == ' o ' ) { computer = ' x ' ; } var computerMove = Math.floor ( Math.random ( ) * 9 ) + 1 ; while ( computerMove == 1 & & ( topLeftBox.innerHTML == ' o ' || topLeftBox.innerHTML == ' x ' ) ) { computerMove = Math.floor ( Mat... | Random Position Choosing for Computer in Tic-Tac-Toe not Working How It 's Supposed to |
JS | I have a problem with link inside page . This is part of jQuery code I use in my pageAnd this is a example DEMOWhen I scroll down everything works fine but when I want go to the top of the page it 's impossible . I know that issue is that the script makes the div fixed , but I do n't know how to fix it . Any ideas ? | $ .fn.stopAtTop= function ( ) { var $ this = this , $ window = $ ( window ) , thisPos = $ this.offset ( ) .top , //thisPreservedTop = $ this.css ( `` top '' ) , setPosition , under , over ; under = function ( ) { if ( $ window.scrollTop ( ) < thisPos ) { $ this.css ( { position : 'absolute ' , top : `` '' } ) ; setPosi... | Anchor does n't work |
JS | I 'm wondering if there are any pros or cons when using the two approaches against each other : first.js : second.js : The two above would then be included and used as so : app.js : | this.myFunction = function ( ) { return 'herro first ' ; } module.exports = obj = { } ; obj.myFunction = function ( ) { return 'herro second ' ; } var first = require ( './first.js ' ) ; console.log ( first.myFunction ( ) ) ; var second = require ( './second ' ) ; console.log ( second.myFunction ( ) ) ; | require ( ) : using module.exports vs assigning to `` this '' directly |
JS | I have a html code : The question is how can I get 1,2,3 as a list using javascript ? I tried : document.getElementById and document.getElementsByClassNameBut none works . | < div id= '' id0 '' class= '' class0 '' > < span > `` 1 '' < /span > < span > `` 2 '' < /span > < span > `` 3 '' < /span > < /div > | Get span elements within div using javascript |
JS | I'am playing with some JavaScript and found something strange.This code alerts `` false '' but gives no syntax errors . Someone could explain why adding one or even many ! ! ! after === is no resulting with any errors ? | var i = void 0 ; var b = i === ! void 0 ? `` true '' : `` false '' ; alert ( b ) ; //display false but no syntax errors.. | What is the `` === ! '' operator doing ? |
JS | Just when I thought I had JS figured out , I get hung up on this : Expected : Actual : So , it seems that if a prototypal property is a reference type , then it is shared across all instances , yet if it 's a non-reference type then it is reinitialized for each instance ; to confirm this hypothesis , I tested a few oth... | function Obj ( ) { console.log ( ' x : % s , o.x : % s ' , this.x++ , this.o.x++ ) ; } Obj.prototype.x = 1 ; Obj.prototype.o = { x : 1 } ; > new Objx : 1 , o.x : 1 > new Objx : 1 , o.x : 1 > new Objx : 1 , o.x : 1 > new Objx : 1 , o.x : 1 > new Objx : 1 , o.x : 2 > new Objx : 1 , o.x : 3 function Obj ( ) { this.o = { x... | Instanced object and properties that are references |
JS | I need to add tags and text in the same input box . The normal text can be delete a character at once . The tags which will be selected from a particular set of words which are pre defined will be deleted all at once . The normal text and tags will be on the same box . The link to fiddle linkSo far I have tried toadd t... | document.querySelector ( '.selectable-icons ' ) .addEventListener ( 'click ' , function ( e ) { document.querySelector ( ' [ contenteditable ] ' ) .appendChild ( e.target.cloneNode ( true ) ) ; } ) ; document.querySelector ( 'div ' ) .addEventListener ( 'keydown ' , function ( event ) { // Check for a backspace if ( ev... | Need to add tags and normal text in same input box |
JS | In a sentence similar to : Lorem ipsum +dolor ++sit amet.I 'd like to match the +dolor but not the ++sit . I can do it with a lookbehind but since JavaScript does not support it I 'm struggling to build a pattern for it . So far I 've tried it with : and to my surprise a pattern like : does n't match anything . I thoug... | ( ? : \+ ( .+ ? ) ) ( ? = [ \s\. ! \ ! ] ) - but it matches both words ( ? : \+ { 1 } ( .+ ? ) ) ( ? = [ \s\. ! \ ! ] ) - the same here - both words are matched ( ? =\s ) ( ? : \+ ( .+ ? ) ) ( ? = [ \s\. ! \ ! ] ) | How to match '+abc ' but not '++abc ' without lookbehind ? |
JS | I 'm reading a book and they show a couple of examples of how to select elements on the DOM , but they advise to always use Jquery trasversing methods over the selectors , for example if you have a list inside a div instead of usingYou should useMost of the time I use the first over the latter , the author says the 2nd... | $ ( `` # myList > li '' ) $ ( `` # myList '' ) .children ( `` li '' ) | Jquery traversing and using selectors |
JS | In my function , I have defined two arrays , the first ( array1 ) , has a pre-initialized length . I added the second array ( array2 ) just for testing because I thought the first was behaving strangely.My code : In the for loop , I try to change the first value of the second dimensions . It should output [ [ 0 , undef... | function test ( n = 3 ) { array1 = new Array ( n ) .fill ( new Array ( n ) ) ; array2 = [ [ undefined , undefined , undefined ] , [ undefined , undefined , undefined ] , [ undefined , undefined , undefined ] ] ; document.getElementById ( `` output '' ) .innerHTML = JSON.stringify ( array1 ) + `` ( array 1 ) < br/ > '' ... | Why do these two javascript 2d-arrays behave differently ? |
JS | Same regex , different results ; JavaJavaScriptI ca n't understand why this is the case ? | String regex = `` Windows ( ? =95|98|NT|2000 ) '' ; String str = `` Windows2000 '' ; Pattern p = Pattern.compile ( regex ) ; Matcher m = p.matcher ( str ) ; System.out.println ( m.matches ( ) ) ; // print false var value = `` Windows2000 '' ; var reg = /Windows ( ? =95|98|NT|2000 ) / ; console.info ( reg.test ( value )... | Same regex have different results in Java and JavaScript |
JS | I 'm writing a function to convert a name into initials . This function return strictly takes two words with one space in between them.The output should be two capital letters with a dot separating them.It should be like this : alex cross = > A.Cjaber ali = > J.AHere is my solutionHave I solved this problem with hardco... | function initialName ( firstLetterFirstName , firstLetterLastName ) { 'use strict ' let x = firstLetterFirstName.charAt ( 0 ) .toUpperCase ( ) ; let y = firstLetterLastName.charAt ( 0 ) .toUpperCase ( ) ; return x + ' . ' + y ; } console.log ( initialName ( 'momin ' , 'riyadh ' ) ) ; // M.R | Abbreviate a two word name in JavaScript |
JS | I noticed that my browser may set a line break after an < img > tag , even if this image tag is followed by & nbsp ; : The smiley should be on the second line , because the image tag is followed by nbsp ; . I can force this behavior by adding a < span > with white-space : nowrap : Is there a solution without adding an ... | < p style= '' width : 12ex ; font-family : monospace ; '' > 12345678 < img style= '' width : 2ex '' src= '' https : //upload.wikimedia.org/wikipedia/commons/thumb/8/85/Smiley.svg/25px-Smiley.svg.png '' > & nbsp ; 123 < /p > < p style= '' width : 12ex ; font-family : monospace ; '' > 12345678 < span style= '' white-spac... | How to prevent linebreaks after an inline image ? |
JS | I 'm beginner on programming . I 've studied Stack Overflow and W3schools , and made my little project just for learning and improving.I have a question , my program is working as it should but the problem is I 'm not sure ( have doubts ) is the json file I made real json or JavaScript object ? One says it is and one s... | < ! DOCTYPE html > < html lang= '' en '' > < head > < meta charset= '' utf-8 '' > < meta name= '' viewport '' content= '' width=device-width , initial-scale=1 '' > < script type= '' text/javascript '' src= '' values.json '' > < /script > < style > * { box-sizing : border-box ; box-sizing : border-box ; -webkit-box-sizi... | Doubts on whether json data or JavaScript object |
JS | we are using magento multi vendor sitewe are using following code to update and cancel price . but once we click on `` cancel '' button textfield is hiding . PHTMLJavascript | < span class= '' label pro_status '' > < ? php //echo $ products- > getPrice ( ) ; ? > < input class= '' ama1 '' type = `` text '' id = `` price_ < ? php echo $ products- > getId ( ) ; ? > '' onkeydown= '' validateNumbers ( event ) '' `` name = `` price '' value = `` < ? php echo $ products- > getPrice ( ) ; ? > '' sty... | Textfield is hiding once we click on cancel button |
JS | Well , all the time i supposed that prototype property exists at all objects . But after one of job interview i came home and open chrome consoleWTF ? OKI 've read https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype several times but still not clear . Can anybody explain ... | window.prototype**undefined** Object.prototype**Object { } ** var a = { } ; a.prototype**undefined**var a = function ( ) { } a.prototype**Object { } ** | Where the ` prototype ` property is defined |
JS | I 'm new to making chrome ( or even browser ) extensions am trying to make one that applies some custom CSS rules to certain page elements . It seems to work generally as expected , with a few slight annoyances.Namely , when I apply any CSS style rules using JS , there seems to be a delay between the page fully renderi... | `` content_scripts '' : [ { `` run_at '' : `` document_start '' , `` all_frames '' : true , `` matches '' : [ `` < all_urls > '' ] , `` js '' : [ `` filter.js '' ] , `` css '' : [ `` filter.css '' ] } ] , | Applying CSS styles from chrome extension to page 'instantly ' before page fully renders |
JS | I have this questionnaire that I use to begin an app . I 'm using javascript to validate before I submit it , but I 'm running into a problem where it is only validating the second button on each question and not validating each question individually . I have posted code below . QuestionnaireJavascriptPlease ask for mo... | < ? for ( $ i = 1 ; $ i < = count ( $ questions ) ; $ i++ ) { print `` < div class='form-group ' > '' ; print `` < div class='col-md-12 ' > '' ; print `` < p > $ i ) `` . $ questions [ $ i-1 ] . `` < /p > '' ; print `` < label class='radio-inline ' > '' ; print `` < input type='radio ' name= ' q $ i ' value= ' 1 ' > Ye... | Radio buttons not validating correctly |
JS | I have two custom filters , I want to filter my data using both these custom filters . But i faced the problem , If I used one by one then they work good , But when I try to use both filters at the same time then no output . My code is as follow : My div is as follow on which I want to apply filter : | < script > var myApp = angular.module ( 'myApp ' , [ ] ) ; myApp.filter ( 'selectedTags ' , function ( ) { return function ( postdata , tags ) { return postdata.filter ( function ( task ) { for ( var i in task.tarn_list ) { if ( tags.indexOf ( task.tarn_list [ i ] ) ! = -1 ) { return true ; } } return false ; } ) ; } ;... | How to filter data based on two custom filters in Angular js |
JS | In a HTML file , I have the following scripts : In script1 , I am loading another HTML file : The code in script2 uses the elements from header.html which is being loaded by script1 . With the current codes , script2 does n't wait for header.html to be completely fetched.A proof of this is that I have added console.log... | < head > < script src= '' /script1.js '' defer > < /script > < script src= '' /script2.js '' defer > < /script > < /head > ( async function ( ) { await fetch ( `` ./header.html '' ) .then ( response = > { return response.text ( ) } ) .then ( data = > { document.getElementById ( `` header '' ) .innerHTML = data ; } ) ; ... | HTML load one script after another script completes execution |
JS | Consider this code : When executed ( in jsfiddle ) , the alert shows that 'this ' is the window object . Changing the last line to : works as expected . Why is the difference ? | function Foo ( ) { } Foo.prototype.alert = function ( ) { alert ( this ) ; } ( new Foo ( ) ) .alert ( ) ; var foo = new Foo ( ) ; foo.alert ( ) ; | why does inline instance creation behave different ? |
JS | I 'm working on a challenge where I have to find the smallest value in an array and be able to count it if the number occurs more than once . I think I have the format down , but it gives me one more count than there are numbers ( 4 instead of 3 ) . Can anyone give me some tips ? Appreciate any help ! | function small ( array ) { var smallest = array [ 0 ] ; var count = 0 ; for ( var i = 0 ; i < array.length ; i++ ) { if ( array [ i ] < smallest ) { smallest = array [ i ] ; } if ( smallest===array [ i ] ) { count++ ; } } return count ; } small ( [ 5,6,2,2,2 ] ) ; | Count the same value number in array |
JS | I am working on a simple project where a single block element hover will show 4x zoom element . I did it through pure css and css3 transition . See the jsfiddle demo . There will be four element , each has different hover element . But when I hover on it only one hover element is showing though it is not associate with... | .main { position : relative ; width : 300px ; overflow : hidden } .main a { width : 50 % ; height : 50 % ; float : left ; } .main a .child { position : absolute ; left : 0 ; right : 0 ; bottom : 0 ; top : 0 ; background : gray ; filter : alpha ( opacity=0 ) ; opacity : 0 ; -webkit-transition : opacity 0.5s ease-out ; -... | element hover not working properly in css3 fade effects |
JS | Given these two examples : andWhich performs faster when a type conversion occurs ? I assume that object type conversion is faster since the primitive gets converted to an object to respond to the expression and then back to primitive again . | var myNumber = 10 ; //primitive var myNumber = new Number ( 10 ) ; //object var myString = myNumber.toString ( ) ; //convert to string | Is type conversion faster for Objects or Primitives in Javascript ? |
JS | I have js libraries that initialize themselves like the following : when built with webpack , I get something likeThe `` this '' is not window as the libraries would assume . Is there a neat way to tame this type of library to work with webpack ? My last resort would be hackly replace the this with window using postloa... | ( function ( root ) { ... ... ... ... } ) ( this ) function ( module , exports ) { ( function ( root ) { } ) ( this ) } | Webpack : How to tame non npm compliant js library |
JS | I need to get all the field names from my collection , including fields in subdocuments . I am currently running this command and getting only the names of the root fields . How can I get all field names ? My collection looks like this : This is the commandI want this result : UserId , Personal.Email , Personal.FirstNa... | `` UserId '' : 11111 , '' Personal '' : { `` Email '' : `` email @ gmail.com '' , `` FirstName '' : `` Name '' , `` LastName '' : `` Last '' } , '' Car '' : { `` CarType '' : `` NULL '' } var mr = db.runCommand ( { `` mapreduce '' : `` myCollection '' , `` map '' : function ( ) { for ( var key in this ) { emit ( key , ... | Get names of all keys in the collection and subdocuments |
JS | I try to translate this Scheme code to Javascript : ( ( double inc ) 0 ) means ( inc ( inc 0 ) ) , so it returns 2.This is my Javascript code : But double ( inc ) ( 0 ) returns undefined , not 2 . Why ? | ( define ( double f ) ( lambda ( x ) ( f ( f x ) ) ) ) ( define ( inc x ) ( + x 1 ) ) ( ( double inc ) 0 ) var double = function ( f ) { return function ( x ) { f ( f ( x ) ) ; } } var inc = function ( x ) { return x+1 ; } double ( inc ) ( 0 ) ; | Why does this code get undefined but not 2 ? |
JS | First of all , I want to say that I 'm huge on theory . I do n't like abstraction . I want to know how things work before trying to use them . I have been searching everywhere for a simple theory behind getting the property name ( not the value ) for a for-in loop . I will demonstrate it in code so hopefully someone ca... | var obj = { one : 1 , two : 2 , three : 3 } ; // A basic object instantiated with 3 public properties.for ( var prop in obj ) { console.log ( prop ) ; // logs `` one '' , `` two '' and `` three '' ? ? ? } var obj = { `` one '' : 1 , `` two '' : 2 , `` three '' : 3 } ; | Simple theory behind getting the property name from a for-in loop ? |
JS | I 'm trying to access a asp.net variable ( c # ) from JavaScript/jQuery.I 've found a solution , here and here . But unfortunately these are not working for me.Here 's a snippet : Default.aspx.csscript.js_currentUser 's value is always `` < % =CurrentUser % > '' .Any ideas ? | public partial class Default : System.Web.UI.Page { public string CurrentUser { get ; set ; } protected void Page_Load ( object sender , EventArgs e ) { CurrentUser = User.Identity.Name.Split ( '\\ ' ) [ 1 ] ; //I need the value of `` CurrentUser '' } ... } $ ( document ) .ready ( function ( ) { var _currentUser = `` <... | Cant access Variables in JS/jQuery via < % = variable % > |
JS | I am encountering a behaviour that I ca n't explain.Depending on using import or require , this test successes ( import ) or fails ( require ) .In case of fail , I have the following error : PhantomJS 2.1.1 ( Windows 7 0.0.0 ) immutability a number is immutable FAILED undefined is not a constructor ( evaluating 'expect... | import { Map , List } from 'immutable ' ; const expect = require ( `` expect '' ) ; // import expectImmutable from `` expect-immutable '' ; const expectImmutable = require ( `` expect-immutable '' ) ; expect.extend ( expectImmutable ) ; describe ( `` immutability '' , ( ) = > { describe ( `` a number '' , ( ) = > { fun... | How does 'require ' operates differently from 'import ' es6 ? |
JS | I have the following code : It outputs : I 've read somewhere that setTimeout adds function to the event queue , and then when this function is the first in the chain it checks whether the specified amount of time has passed , if not , it postpones execution . Under this logic I expected the above code to output : 2,3,... | function wait ( ms ) { var start = + ( new Date ( ) ) ; while ( new Date ( ) - start < ms ) ; } ( function ( ) { setTimeout ( function ( ) { console.log ( 2 ) } , 1000 ) ; setTimeout ( function ( ) { console.log ( 3 ) } , 0 ) ; setTimeout ( function ( ) { console.log ( 4 ) } , 0 ) ; wait ( 2000 ) ; // ! ! ! blocking ev... | Why setTimeout outputs numbers not in order added |
JS | EDITI was a bit quick there , the problem arises in the function and not where I first said . Here is the function : Does that make it clearer ? END EDITOk so , I have a little problem.I have a function that returns a fairly simple object , which looks something like this : I save it to a variable like this : Why is th... | function returnAnObject ( url ) { var apiurl = 'http : //url.com ' ; var info = { } ; $ .getJSON ( apiurl , function ( data ) { $ .extend ( info , { a : data.x , b : data.y , c : data.z } ) ; } ) ; console.log ( info ) ; // Shows object as usual console.log ( info.a ) ; // Shows undefined return info ; } { a : ' x ' , ... | JavaScript object returned from function available in Chrome Dev Tools , but not from script |
JS | Have a tree structure like the followingI can click on any item and hide all the other items with the dynatree onActivate function and this codeMy html is thisHow can I extend this html and function so if I click `` Section 1 '' in the tree it shows all the items in that section only i.e . clicking `` Section 1 '' only... | Section 1item1item2Section 2item5 onActivate : function ( node ) { var resultId = `` # '' + node.data.title ; resultId = resultId.replace ( /\s/g , `` ) ; $ ( ' # contents > div ' ) .not ( resultId ) .hide ( ) ; $ ( resultId ) .show ( ) ; } , < div class= '' container-fluid text-left '' > < div class= '' row content ''... | Hide Sections Clicking Dynatree Value |
JS | Currently I have a code that looks like this : I need to make the file size smaller , but I do n't know how to replicate the code in `` vanilla '' javascript . Please help ! | $ ( ' a.guide-item [ href= '' / '' ] ' ) .remove ( ) ; $ ( '* [ href= '' / '' ] ' ) .attr ( 'href ' , '/feed/subscriptions/u ' ) ; | How to make this code work without jQuery ? |
JS | I have seen people doing the following way of coding lot of times but as I usually do n't do it and it works fine with me without it , I am just curious on whether it is important or not.Note : I marked the lines I am talking about as // this line | function Test ( name , something ) { this.name = name ; this.something = something } Test.prototype.name = `` ; // this lineTest.prototype.something = `` ; // this lineTest.prototype.getName = function ( ) { return this.name ; } | why some people define the prototype property value of javascript object |
JS | I 've got this issue when a variable is missing a field and the user gets to see the warning that this or that variable does n't have this or that property . In the simple case it 's very straight-forward.However , in empirical situations , I 've found myself getting to this absurd over-checking.I mean , c'mon - the pi... | if ( field ) doSomething ( field.subField ) ; if ( ! data || ! data.records || ! data.records [ 0 ] || ! data.records [ 0 ] .field || ! data.records [ 0 ] .field.id ) return null ; doSomething ( data ) ; | How many checks against null is appropriate ? |
JS | I am building one application in AngularJS and I have very complex JSON file which have so many child arrays and objects . So my question is : for accessing the data from JSON is it OK to use ng-repeat again and again ? -- -- - OR there is some looping method is available in AngularJS -- -- - OR we have to use old Java... | < div ng-repeat= '' parent in parents '' > < div ng-repeat= '' child in parent '' > < div ng-repeat= '' grandChild in child '' > { { grandChild.name } } < /div > < /div > < /div > { `` data '' : { `` categories '' : { `` articles '' : { `` bdh '' : [ { `` id '' :1 , `` name '' : '' bdh article 1 '' , `` body '' : '' th... | Is it OK to use ng-repeat again and again ? |
JS | I followed an instruction to trigger the JavascriptInterface from a webview , but it isnt triggered in my case.I have an class QuickTextViewer with following : I also added the following to proguard-rules.pro ( actually public only for testing ) In my case onPageFinished is triggered but resize ( ) not ! Any suggestion... | public class QuickTextViewer { private WebView webView ; ... ... public QuickTextViewer ( ) { webView = dialog.findViewById ( R.id.mywebview ) ; webView.setWebViewClient ( new WebViewClient ( ) { @ Override public void onPageFinished ( WebView view , String url ) { view.loadUrl ( `` javascript : MyApp.resize ( document... | triggering JavascriptInterface from a android webview |
JS | Right now I 'm trying to write a jquery function which lets me expand a div when you click it , then return it to its initial size when you click it again . I tried adding a button to make it retract , but because when I click it the script thinks I 'm also clicking the parent div and expands again . Ideally , I 'd lik... | < div class= '' grid '' > < div class= '' block '' id= '' block1 '' > < button class= '' retractor '' id= '' ret1 '' > back < /button > < /div > < div class= '' block '' id= '' block2 '' > 2 < /div > < div class= '' block '' id= '' block3 '' > 3 < /div > < div class= '' block '' id= '' block4 '' > 4 < /div > < div clas... | How do I turn this jQuery function into an 'if ' statement |
JS | I have a stream randStream which emit random value every half second and boolStream which converts value from randStream into boolean.I want to emit true when boolStream emits true for 5 seconds ( in a row ) . Otherwise emit false . I 'm using Kefir.js library.Do you have any ideas ? Thanks . | let randStream = Kefir.fromPoll ( 500 , ( ) = > Math.random ( ) ) let boolStream = Kefir.map ( ( rand ) = > rand > 0.5 ) | Reactive programming - value is greater than X for N seconds |
JS | In Javascript , I have an array of objects like so : which looks like this , really ... and I delete the second one : then I have this : How can I adjust this array so the keys are back in numerical order ? | var array = [ { foo : 'bar ' } , { foo : 'baz ' } , { foo : 'qux ' } ] ; [ 0 : { ... } , 1 : { ... } , 2 : { ... } ] delete array [ 1 ] ; [ 0 : { ... } , 2 : { ... } ] | Adjusting object keys after deleting key |
JS | I am trying to let the icons ( wich will be buttons in the future ) stay hidden until the right word is placed in the tab the button is in too , so when it 's all done you can only click the icon if you 've set the right word in the right tab and some audio will play.. but I ca n't seem to figure out how to let the ico... | $ ( document ) .ready ( function ( ) { var rigtige = 0 ; //good_points var forkerte = 0 ; //false_points var answers ; var footer ; var timer = setInterval ( function ( ) { getReady ( ) ; } , 203 ) ; var number = [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ] ; //define JSON arrays ( jsonData_0_123.json ) function getReady ( ) { if... | icon stays hidden until something is moved there |
JS | I have an array that looks like so : I want to make it look like this : I have the following so far : I am having difficulties figuring out a decent way to do this . What I have so far already does n't work because it creates two objects under navigation each with title : `` Dashboard '' . Any ideas for a clever approa... | files = [ 'Dashboard/Logs/Errors ' , 'Dashboard/Logs/Other ' , 'Accounts/Main ' , ] navigation = [ { `` title '' : `` Dashboard '' , `` dropdown '' : [ { `` title '' : `` Logs '' , `` dropdown '' : [ { `` title '' : `` Errors '' , } , { `` title '' : `` Other '' , } ] } ] } , { `` title '' : `` Accounts '' , `` dropdow... | Javascript Array to Object |
JS | I am learning Angular 2 and trying to follow their tutorial.Here is the code of the service that returns `` Promise '' of a mock object Folder.It is declared in providers of my FolderModuleFolder component should import FolderService and use it to obtain the Folder object.And yes , i do import my FolderModule in the ro... | import { Injectable , OnInit } from `` @ angular/core '' ; import { FOLDER } from `` ./mock-folder '' ; import { Folder } from `` ./folder '' ; @ Injectable ( ) export class FolderService { getFolder ( ) : Promise < Folder > { return Promise.resolve ( FOLDER ) ; } } import { NgModule } from `` @ angular/core '' ; impor... | Angular 2 component DOM binds to the property in component before it has bean resolved in OnInit method |
JS | I am working on alpha.dubaiexporters.com.There is a go button clicking on which a search panel appears where I can perform search keyword and category.The issue is that after clicking on go button , search panel appears but if the user does not want to perform any search , he clicks outside anywhere but that search pan... | http : //alpha.dubaiexporters.com/aboutus.aspx < header class= '' header vc_row-fluid vc_col-sm-12 '' > < div class= '' top-header vc_col-sm-12 '' > < div class= '' logo shadows vc_col-sm-3 '' > < a href= '' Default.aspx '' > < img src= '' images/layout/check1.png '' width= '' 230 '' height= '' 69 '' alt= '' Dubai Expo... | How to close a div by clicking outside anywhere ? |
JS | I have an array of arrays , of the same size , of objects like this : How do I merge these arrays object by object to have an output like this ? If it could be using lodash , it would be nice too . Thanks in advance | const array = [ [ { name : 'John ' } , { name : 'Julie ' } , { name : 'Zack ' } ] , [ { color : 'blue ' } , { color : 'orange ' } , { color : 'green ' } ] , [ { age : 12 } , { age : 10 } , { age : 35 } ] ] ; const result = [ { name : 'John ' , color : 'blue ' , age : 12 } , { name : 'Julie ' , color : 'orange ' , age :... | Merge arrays object by object |
JS | I have a Array that I am turning into a new one that 's suitable for my work . This is the original ArrayI have : Note : 'jayanagar ' , 'mallashwaram ' , 'kolar ' are referred as city in my code.And from this I am converting it into this : What I am trying to do isAs you can see in arra1 I have two years , i.e 2018-8 a... | var array1= [ [ `` Year '' , `` 2018-8 '' , `` 2017-8 '' ] , [ `` JAYANAGAR '' , `` 2018-8 '' , 10910665 ] , [ `` MALLESHWARAM '' , `` 2018-8 '' , 2018451 ] , [ `` KOLAR '' , `` 2018-8 '' , 2277562 ] , [ `` JAYANAGAR '' , `` 2017-8 '' , 1134 ] ] var array2= [ [ `` Year '' , `` Jul 2018 '' , `` Jul 2017 '' ] , [ `` JAYA... | Converting existing Array into a new one |
JS | I am going to start off by saying that I do n't think this is possible , but hoping that someone knows some special way in JavaScript to do this . I have a JavaScript object defined as follows : I am looking for a way so that I can define the same element of an array twice with different values that could be used in tw... | var t = { `` fields '' : { `` a '' : [ `` 99 '' , `` 98 '' ] } } ; var t = { `` fields '' : { `` a '' : [ `` 99 '' , `` 98 '' ] , `` a '' : `` 99|98 '' } } ; | JavaScript Object - Different Type Depending on Context |
JS | On inputting the following function call into chrome console : I get the following results : Can someone explain why the 3rd and 5th tests return false ? And why the First and Second both return true . | ( function ( regex , str ) { console.log ( regex.test ( str ) ) console.log ( ! regex.test ( str ) ) console.log ( ! regex.test ( str ) ) console.log ( ! regex.test ( str ) ) console.log ( ! regex.test ( str ) ) } ) ( new RegExp ( `` new '' , `` gmi '' ) , `` new '' ) truetruefalsetruefalse | Javascript : Insane boolean test with ' ! ' operator |
JS | I have prepared this jsfiddle that ilustrates how my script calculate twice the sum of each selected option attribute price . Please help me to solve this issue.optionsamount is wrong , I mean is calculated twice.. Why is that ? Thanks | function update_amounts ( ) { var sum = 0.0 ; var optionsamount = 0.0 ; $ ( ' # basketorder > tbody > .product ' ) .each ( function ( ) { $ ( '.selectedoptionselect option : selected ' ) .each ( function ( ) { optprice = $ ( this ) .attr ( 'price ' ) ; optionsamount+= parseFloat ( optprice ) ; } ) var qty = $ ( this ) ... | JS script to calculates sum of amount calculates wrong |
JS | Here 's the jsfiddle simulating my problem relating to this code : I was expecting the # img1 element to fade in and then for the execution to stop for 1 second and then fade out , then start over for the # img2 element etc . | $ ( ' # button ' ) .click ( function ( ) { var i ; for ( i = 1 ; i < 4 ; ++i ) { $ ( ' # img ' + i ) .fadeIn ( `` slow '' ) .delay ( 1000 ) ; $ ( ' # img ' + i ) .fadeOut ( `` slow '' ) ; } } ) ; | Why are all the iterations run at the same time ? |
JS | Today I dove into the internals of Webpack and I managed to use a lot of its usefull features ( via Webpack loaders ) such as CSS modules and the Babel transpiler . I want to use this to make a React app ( without create-react-app ) .Here is my config file : Because I now have a single entry point my whole bundle gets ... | const HtmlWebPackPlugin = require ( `` html-webpack-plugin '' ) ; const path = require ( 'path ' ) ; module.exports = { entry : { main : './src/index.js ' , } , output : { path : path.resolve ( __dirname , 'dist ' ) , filename : ' [ name ] .js ' } , module : { rules : [ { test : /\.js|jsx $ / , exclude : /node_modules/... | React , creating optimal production bundles with webpack |
JS | I need to count the blue bars ' longest streak till the bar we are hovering over for the bar diagram obtained by code below : For e.g . If I hover on first bar ( which is red ) the Longest streak should show 0 , second hover ( which is also red ) also 0 . When hovered on third bar that is blue it should show 1. and unt... | body { font : 10px sans-serif ; } .axis path , .axis line { fill : none ; stroke : # 000 ; shape-rendering : crispEdges ; } .bar { fill : orange ; } .bar : hover { fill : cyan ; } .x.axis path { display : none ; } .grid .tick { stroke : lightgrey ; opacity : 0.7 ; } .grid path { stroke-width : 0 ; } .d3-tip { line-heig... | Counting the number of continuous blue bars till the hover bar |
JS | I am having trouble automatically calculating the working days of different online stores that open at different days . The difficulty here is some of the stores open during the weekends . What i realized was JavaScript starts counting the days of the week from 0 which is a Sunday.because Sunday returns 0 from JavaScri... | examplestore A , WORKING_DAYS = Tue - Sunstore B , WORKING_DAYS = Mon - Fristore C , WORKING_DAYS = Mon - Tuestore D , WORKING_DAYS = Fri - Mon // 0 ( sunday ) - 6 ( saturday ) give day is thursay which is 4 // workdays fri - tues , ie 5 - 2 but current day is saturday and we looking at positive values if ( dayStart < ... | How do I calculate the opening days of online stores with different working days . ? |
JS | We can achieve iteration on array-like objects using both of the following methods : Or using slice to convert array-like objects to array first : Which one is more preferrable and why in the case where I need not the converted array-like object ? The first one feels a little 'hacky ' but the second one feels more read... | let arrayLike = document.getElementsByClassName ( 'dummy ' ) ; [ ] .forEach.call ( arrayLike , ( e ) = > { console.log ( e ) ; } ) ; < div class = `` dummy '' > Test1 < /div > < div class = `` dummy '' > Test2 < /div > let arrayLike = document.getElementsByClassName ( 'dummy ' ) ; Array.prototype.slice.call ( arrayLike... | Iterating array-like objects using forEach , [ ] .forEach.call ( ... ) or Array.prototype.slice.call ( ... ) .forEach ? |
JS | example : I 'm not interested in How this happens , I want to know why the language has this feature . | x = `` Hello '' ; delete x ; // returns true , x is removedvar y = `` Hello '' ; delete y ; // returns false , y is not removed | Why ca n't I delete javascript values declared with var ? |
JS | I have the following JavaScript code : Can you explain why the alert pops up with 2 and not 1 ? Thanks , | ( function ( ) { function f ( ) { alert ( 1 ) ; } return f ( ) ; function f ( ) { alert ( 2 ) ; } } ) ( ) ; | Why does second function declaration win even though I return before it ? |
JS | I have a function that has a values inserted into variables in another function.Initialise : When the window resizes , it fires the resizeImage ( ) function.Resize Function : This function checks every element with the image-resize class and add readjust the SRC for the image by changing the width value ( dynamic from ... | $ ( window ) .resize ( function ( ) { resizeImage ( ) ; } ) ; function resizeImage ( ) { $ ( '.image-resize ' ) .each ( function ( ) { var element = $ ( this ) , src = $ ( this ) .attr ( 'src ' ) , regx = /wid=\d+ ( \.\d ) */g , currentWidth , newWidth , newSrc ; var attrElement = $ ( this ) , attrSrc = $ ( this ) .att... | Access variable from function |
JS | Say we have three buttons on our site : Each button will call their respective functions : And in the controller it could look something like this : Since cluttering the $ scope with too many watchers is bad for performance , would n't it be better to do this : And then using it like : Which will reduce the number of w... | < button > Like < /button > < button > Dislike < /button > < button > Flag < /button > < button ng-click= '' like ( ) '' > Like < /button > < button ng-click= '' dislike ( ) '' > Dislike < /button > < button ng-click= '' flag ( ) '' > Flag < /button > $ scope.like = function ( ) { return likes + 1 ; } $ scope.dislike =... | Is it better to create objects containing functionality or have loose functions in AngularJS controllers ? |
JS | I found a bug in a script that was written , and I 'm having troubles figuring out exactly what is causing the issues . Specifically : There 's two different conversions I can think of here : I fixed it with : So why does this evaluate to false ? What exactly is happening here ? | `` 49px '' < 50 === false 49 < 50 === true '' 49px '' < `` 50 '' === true '' 49 '' < 50 === true // just for the hell of it parseInt ( `` 49px '' ) < 50 === true | What Javascript type conversions are happening here ? |
JS | In JavaScript the following line of code gives answer as 1I could n't understand how ? Any gurus explanation is appreciated . | + ! { } [ true ] | What would be the explanation for the strange javascript expression ? |
JS | I have multiple divs with ids like course1_popup , course2_popup , course3_popup . I want to make a function something likeso that all course*_popup divs should hide but this is not working . Any Ideas ? | $ ( ' # course*_popup ' ) .hide ( ) ; | How to select element has id start and end with specific text using jquery ? |
JS | Can someone explain in detail what is going on here ? Specifically the double dot notation.source | ( 3.14 ) .toFixed ( ) ; // `` 3 '' 3.14.toFixed ( ) ; // `` 3 '' ( 3 ) .toFixed ( ) ; // `` 3 '' 3.toFixed ( ) ; // SyntaxError : Unexpected token ILLEGAL3..toFixed ( ) ; // `` 3 '' | What is this javascript syntax ? |
JS | I found this syntax in the simple , great , wonderful and powerful library knockoutjs : What is the meaning of the not sign ( ! ) before the function declaration ? UPDATE : The source code no longer contains this exact syntax . | ! function ( factory ) { ... } | What does the syntax ! function ( ) { ... } mean ? |
JS | I have a small MySQL database with a few hundred rows ( all in text , no images ) . I am requesting all the rows using iQuery and do all filtering at client end . iQuery code is the following : On the server side , the `` alldata.php '' has the following code and pass the data in JSON back to iQuery : It seems to me th... | $ ( document ) .ready ( function ( ) { $ .get ( `` alldata.php '' , function ( data ) { $ ( ' # result ' ) .text ( data ) ; } ) ; } ) ; $ sql = `` SELECT title FROM mydatabase '' ; $ result = mysqli_query ( $ conn , $ sql ) ; $ arr = array ( ) ; while ( $ row = mysqli_fetch_assoc ( $ result ) ) { $ row_array [ 'Title '... | Is there any injection risk if no user input was sent to database ? |
JS | I have a class box2 , and box , box contains value randomly selected from array2 which is a duplicate of array itemsWhen the dragged element url matches with dropped element label the background color disappears . I have given condition if tempimages==0 the random selection happens once again . ie , when drop is at the... | var items = [ { label : ' 1:40 ' , url : 'https : //via.placeholder.com/75x75 ? text=1 ' } , { label : ' 2:20 ' , url : 'https : //via.placeholder.com/75x75 ? text=2 ' } , { label : ' 3:50 ' , url : 'https : //via.placeholder.com/75x75 ? text=3 ' } , { label : ' 4:45 ' , url : 'https : //via.placeholder.com/75x75 ? tex... | Reloading values into array happens one place before than last place in javascript |
JS | I 'm not sure if the title of this question is correct or not and also not sure what the appropriate keyword to search on google.I have an array look like : and I want to sort my array into : Please in to my expected result . the order is ascending but duplicate value will repeated on last sequence instead of put it to... | var myArray = [ 1,1,2,2,2,3,4,4,4 ] ; var myArray = [ 1,2,3,4,1,2,4,2,4 ] ; | How to sort an array sequencial in javascript ? |
JS | Let 's say I have this HTML ... ... and this JavaScript.Now I would like to prompt the user with a confirm dialogue before removing all those things . Is there a way to do it without adding and calling confirm inside every single click handler ? I have on my mind something like adding a single class to all of the diffe... | < button class= '' btn-remove-this '' > Remove this < /button > < button class= '' btn-remove-that '' > Remove that < /button > < button class= '' btn-remove-some-other-thing '' > Remove some other thing < /button > < ! -- and many more 'Remove ... ' buttons -- > $ ( function ( ) { $ ( '.btn-remove-this ' ) .click ( fu... | How to add a confirm dialogue to many different buttons at once with jQuery ? |
JS | Is there any way i can change all links at once under option tag ? For Example : ... . And so on around 100 links .Now i want to change link website.com to m.website.com furthur link remains same . Like m.website.com/1001 , m.website.com/1002 | < select size= '' 1 '' name= '' links '' onchange= '' window.location.href=this.value ; '' > < option value= '' http : //website.com/1001/ '' > Blue < /option > < /select > < br > < select size= '' 1 '' name= '' links '' onchange= '' window.location.href=this.value ; '' > < option value= '' http : //website.com/2001/ '... | Change all links at once |
JS | I have five paragraphs on my front end as below : In JS I wrote the following : I know when I click on the button it hides all the p tags , so it would be great if any one can tell me how I would be able to hide the third paragraph only . | < form id= '' form1 '' runat= '' server '' > < div id= '' div '' > < p > para1 < /p > < p > para2 < /p > < p > para3 < /p > < p > para4 < /p > < p > para5 < /p > < asp : Button id= '' button '' runat= '' server '' Text= '' Click to hide para3 ! '' / > < /div > < /form > $ ( `` # button '' ) .click ( function ( ) { $ ( ... | Hide the 3rd paragraph out of 5 paragraphs on a click of a button , with out assigning any class or id to the paragraphs |
JS | Due to problems with autoscrolling , I had to replace my blog theme on Tumblr . On this new theme all external links open on a new tab , even after deleting all the target= '' _blank '' > on the code.When I try the code on the blog itself it puts the target= '' _blank '' > back in the code.If for example I leave a link... | < a href= '' EXTERNAL-WEB-SITE-GOES-HERE '' > < svg class= '' social-accounts-icon '' xmlns= '' http : //www.w3.org/2000/svg '' xmlns : xlink= '' http : //www.w3.org/1999/xlink '' x= '' 0px '' y= '' 0px '' viewBox= '' 0 0 242.8 242.8 '' enable-background= '' new 0 0 242.8 242.8 '' xml : space= '' preserve '' > < path f... | How to force an external link to open on the same tab in a Tumblr theme ? |
JS | This code I post is an image , Html and css code.. when i click on check box image but not open sub < li > . if i write the code this . but sub < li > open very fast.any one tell me ? ? In this image see its look of code . | $ ( `` # menu1 li a '' ) .click ( function ( ) { $ ( this ) .next ( `` ul '' ) .toggle ( ) ; } ) ; < script > $ ( `` # menu1 li a '' ) .click ( function ( ) { $ ( this ) .next ( `` ul '' ) .toggle ( `` slow '' ) ; } ) ; $ ( `` # menu2 li a '' ) .click ( function ( ) { $ ( this ) .next ( `` ul '' ) .toggle ( `` slow '' ... | i add this code but now sub < li > menu list not open..action performed but not open the menu |
JS | JSFiddle hereI 'm trying to add tooltips to an existing page . We already use bootstrap 2.3 so it seemed like the obvious choice . My html looks like this , say : and my CSS looks like : When I mouseover the button , the tooltip displayed just as I wanted first time , but the styling on the button itself also appears t... | < script > //initialize tooltips $ ( document ) .ready ( function ( ) { $ ( '.my_button ' ) .tooltip ( ) ; } ) ; < div class= '' my_button_row '' > < a href= '' www.google.com '' data-placement='bottom ' data-toggle= '' tooltip '' title= '' Some helpful text here ! '' class= '' my_button my_button_green '' > buttonnnnn... | Adding bootstrap tooltip modifies the style of the element itself - how do I stop this happening ? |
JS | [ EDIT ] Thanks for the help from prasad and Vijayp , i solved the the issue of setting up borders . However , another question is not fully addressed . I apologized for not making it clear.My question is that after dynamically created the table . You can see there are 5 horenzontal borders . ( Please see picture below... | /* js : */ $ ( document ) .ready ( function ( ) { var table = document.createElement ( 'table ' ) ; for ( var i = 0 ; i < 4 ; i++ ) { var tr = document.createElement ( 'tr ' ) ; var td1 = document.createElement ( 'td ' ) ; // assign the id td1.id = i ; tr.appendChild ( td1 ) ; table.appendChild ( tr ) ; td1.className =... | Have trouble assigning the id when creating the table dynamically using javaScript |
JS | I am trying to understand a code I found on the internet . I dont't understand in the while loop , why it is not an infinite loop . If change the calculator.appendChild in it to e.g . console.log it runs forever.Basically there is always a first child in a non-empty site , so the condition is always true . Can someone ... | window.location.hash = 1 ; var calculator = document.createElement ( `` div '' ) ; calculator.id = `` height-calculator '' ; while ( document.body.firstChild ) { calculator.appendChild ( document.body.firstChild ) ; } document.body.appendChild ( calculator ) ; document.title = calculator.clientHeight ; | Why does n't this script end in infinite loop ? |
JS | Currently I have calls like this all over my three controllers : I see lots of advice to encapsulate the $ http calls into an HttpService , or some such , but that it is much better practice to return the promise than return the data . Yet if I return the promise , all but one line in my controller $ http call changes ... | $ scope.getCurrentUser = function ( ) { $ http.post ( `` /Account/CurrentUser '' , { } , postOptions ) .then ( function ( data ) { var result = angular.fromJson ( data.data ) ; if ( result ! = null ) { $ scope.currentUser = result.id ; } } , function ( data ) { alert ( `` Browser failed to get current user . `` ) ; } )... | Why move my $ http calls into a service ? |
JS | Suppose I have a function that takes a generator and returns another generator of the first n elements : Usage like this : Now imagine that evens is also async ( see this answer for setup ) : This , of course , does not work with take : Now , I can define a take variant that is async : ... but what a hassle ! Is there ... | const take = function * ( n , xs ) { console.assert ( n > = 0 ) ; let i = 0 ; for ( const x of xs ) { if ( i == n ) { break ; } yield x ; i++ ; } } ; const evens = function * ( ) { let i = 0 ; while ( true ) { yield i ; i += 2 ; } } ; for ( const x of take ( 10 , evens ( ) ) ) { console.log ( x ) ; } const evensAsync =... | Raising function * into async function * ? |
JS | So , I 've been hunting and I ca n't seem to find anything unless my searching skills have gotten worse lately . But , what I 'm looking for is to be able to generate two vendor bundles based on the entry point.For example , I have 3 entry points : EditorPublicAuthWhen a user is logged in , it 'll include a variation o... | optimization : { concatenateModules : true , splitChunks : { cacheGroups : { commons : { test : / [ \\/ ] node_modules [ \\/ ] / , name : 'vendors ' , minChunks : 2 , chunks : 'all ' } } } } , | Webpack4 : Two vendor libraries based on entry points |
JS | I 've made a CSS animation and some JavaScript code to update the animation speed . It seems that my JavaScript code is valid but that once the speed is set in CSS it can no longer be updated . If I do n't set the speed in CSS the JavaScript works perfectly fine . If the last two lines in the css above are removed the ... | # circle1 { width : 200px ; height : 200px ; background : blue ; -webkit-animation : upDown 5s infinite ; /* Safari and Chrome */ animation : upDown 5s infinite ; } document.getElementById ( 'circle1 ' ) .style.webkitAnimationName = 'upDown ' ; document.getElementById ( 'circle1 ' ) .style.webkitAnimationDuration = '40... | Why ca n't speed be changed on CSS animation with JavaScript |
JS | I 'm using Webpack to bundle my JavaScript application . I saw a developer during a talk that had a line similar to this : ORWhat does the @ symbol mean in this case ? A co-worker thought that it might be a shortcut to node_modules , and it 's extremely difficult to get good search results for this type of question due... | var foo = require ( ' @ /foo/bar ' ) ; import ' @ /foo/bar ' ; | When bundling JavaScript with Webpack , what does the @ symbol mean at the beginning of the require/import URL ? |
JS | I have a problem with the implementation of setInterval . I have created a slider in which the setInterval processes a function every few seconds . I have noticed after few minutes and few rounds of the execution of setInterval an additional delay is incurring.Please suggest what seems to be the problem here ? https : ... | $ ( document ) .ready ( function ( ) { var totalItems = $ ( '.sliderItem ' , ' # slider ' ) .length ; var currentIndex = $ ( '.itemActive ' ) .index ( ) + 1 ; var slideTime = 3000 ; function goNext ( e ) { $ ( '.sliderItem ' ) .eq ( e ) .fadeOut ( 500 ) ; $ ( '.welcomeBox > .welcomeText1 ' , '.sliderItem ' ) .eq ( e ) ... | SetInterval creates delay after many rounds of execution |
JS | I 'm trying to build a Pomodoro clock like http : //codepen.io/GeoffStorbeck/full/RPbGxZ/ . The value of seconds goes to NaN randomly and then returns to normal after starting 'break'.Here 's the link to the codepenhttp : //codepen.io/ibrahimjarif/pen/wMKJWNHow do I fix the NaN issue ? And is there any better way to im... | $ ( ' # circle a ' ) .click ( function ( ) { var timer = $ ( '.time > span ' ) .html ( ) ; timer = timer.split ( ' : ' ) ; var minutes = timer [ 0 ] ; //Value of minutes var seconds = timer [ 1 ] ; //Value of seconds var settimer = setInterval ( function ( ) { seconds -= 1 ; console.log ( seconds ) ; if ( seconds < 0 &... | Pomodoro Timer : Variable value goes to 'NaN ' |
JS | I have a chain of several maps , one of which needs to perform a database operation for each array element , so I 'm using async await.This is n't a problem if it is the last item in the chain because I can unwrap it with Promise.allHowever , there are other synchronous operations I need to perform afterward , so I 'd ... | const resultsAsPromises = arr .map ( syncDouble ) .map ( asyncMapper ) console.log ( 'results ' , await Promise.all ( resultsAsPromises ) ) function extractPromiseValues ( value ) { return value.then ( v = > v ) ; } var arr = [ 1 , 2 , 3 , 4 , 5 ] ; function timeout ( i ) { return new Promise ( ( resolve ) = > { setTim... | How Can I Unwrap an Array of Promises within a Chain of Array Methods ? |
JS | I am trying to add an action in amcharts like : When I replace 'myfunc ( ) ' by 'alert ( 1 ) ' it launch an alert but myfunc defined in code launch an error in console 'Uncaught ReferenceError : myfunc is not defined ' . why ? how can I solve this issue ? My intention was create a more elaborated function with jquery l... | function myfunc ( name ) { alert ( `` hi `` +name ) ; } var tooltipDetail= ' < div class= '' detail '' name= '' { name } '' onclick= '' myfunc ( { name } ) ; '' > detail { name } < /div > 'series1.columns.template.tooltipHTML = tooltipDetail ; $ ( '.detail ' ) .click ( function ( ) { var name=this.attr ( `` name '' ) ;... | amcharts : How to add an action in tooltip |
JS | I want to make sure that the URL I get from window.location does not already contain a specific fragment identifier already . If it does , I must remove it . So I must search the URL , and find the string that starts with mp- and continues until the end URL or the next # ( Just in case the URL contains more than one fr... | www.site.com/ # mp-1 -- > www.site.com/www.site.com # mp-1 -- > www.site.comwww.site.com/ # mp-1 # pic -- > www.site.com/ # pic var url = window.location ; if ( url.toLowerCase ( ) .indexOf ( `` # mp- '' ) > = 0 ) { var imgString = url.substring ( url.indexOf ( ' # mp- ' ) + 4 , url.indexOf ( ' # ' ) ) ; console.log ( ... | Removing a letters located between to specific string |
JS | I have 2 node js programs.The first program 's result is 12559.The second program 's result is 13870.Why does the second program use more memory but still has a larger call stack maximum size ? UPDATE : If we change the program as follow : The maximum recursion depth is decreased . Because Stack memory is used to store... | console.log ( 'TEST A : ' ) ; function computeMaxCallStackSizeA ( ) { try { return 1 + computeMaxCallStackSizeA ( ) ; } catch ( e ) { return 1 ; } } for ( let i = 0 ; i < 5 ; i++ ) console.log ( computeMaxCallStackSizeA ( ) ) ; console.log ( '\nTEST B : ' ) ; function computeMaxCallStackSizeB ( ) { try { let a = [ ] ; ... | How to estimate javascript call stack maximum size ? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.