Javascript What does 'Error: uncaught exception: Syntax error, unrecognized expression: [object Object]' mean in jQuery?

I keep getting this error: Error: uncaught exception: Syntax error, unrecognized expression: [object Object] There is no line number or anything associated with it. It comes from this script: http://www.fissiondesigns.com/simon/. Try drawing a square on the picture to reproduce. What does the error mean and how do I prevent it?

CSS pseudo class won't work when normal class is set from javascript, under FF

I have p.first_p:first-letter in my stylesheet, as I checked, it works well when class first_p is set in HTML. Problems start when I use javascript to find elements and then set their class. Under Chrome and Opera it works fine (I need to check IE 8 and 9, and FF3). FF 5.01 changes the class, but still pseudo class setting doesn't affect the element. It seems that FF needs to 'refresh' css settings of element before pseudo class starts working, so I made rather dirty workaround - script repl

Javascript I need to find prototype.js based slide out tab?

I have founded this -> http://www.building58.com/examples/tabSlideOut.html But there are some reasons that i dont want to use it: i need prototype framework instead of jquery i need an image to open slider (click to open) and when it opened image will change to "click to close" Maybe someone has already the same solution of my question? thank for you help!

Internationalization and localization of existing JavaScript applications

So far I'm using Globalize for i18n and l10n of my JavaScript apps (built with jQuery UI). This works, but it ties my code to another specific library. Now I'm looking for a way to overcome this issue because I reuse some source that does not support i18n right now and I would rather not change this. I'm not talking about using a global interface for i18n where I could plug in any implementation. To summarize: How do I add i18n and l10n support to existing applications without changing it's sou

Javascript Some of my application initializers don't seem to trigger?

I have a top level application called SearchApp which has a sub-app called TeamApp. The files are structured like this: search_app.js.coffee # The top-level application. team_app/ app.js.coffee team_list.js.coffee team_invite.js.coffee I initialize my application in search_app.js.coffee: window.Domainer = {} # This is the top level application. Domainer.SearchApp = new Backbone.Marionette.Application() # Assign a region to the Application. Domainer.SearchApp.addRegions(stage: '#stage

redirect to html page using javascript

i have 2 html page the first one is the login page and the second, when i login i redirect to the main page, there is a must must execute on load, only at the first load of the page after login this method must call. when i reload or refresh this method is call again. 1- can i refresh the page without calling the onload method? if yes how? or 2- can i redirect to a specific method in the page to avoid calling the onload method every time? if yes how or 3- can i write any thing in the onloa

Javascript Non property assigned variable is delete-able

I was reading this article on the Javascript delete method, and tried this code: function f(){ var x = "abcd"; console.log(delete x); //returns false, because x has DontDelete attribute y = "abcd"; console.log(delete y); //returns true, but I didn't explicitly assign y as a property } This is strange, because I am not using property assignment for y (as in: window.y="abcd";), which the article claims is how you make properties deleteable. Why does y not have the DontDelete a

Javascript Get the position of the clicked list item

lets say we have this markup: <header> <nav> <ul> <li><a href="">first (not)</a></li> <li><a href="">second</a></li> <li><a href="">third</a></li> <!-- ... more here --> </ul> </nav> </header> I found out about .index() function I'm trying like this: $('body').on('click','header :not(li:first-child a) a',function(e){ e.p

`Div.backgroundColor` change to `Element.backgroundColor` using Javascript

I would like to change #Content.backgroundColor to elem.backgroundColor using JavaScript. Here is HTML codes : <button class="red" onClick="changeColor(this);">Btn1</button> <button class="blue" onClick="changeColor(this);">Btn2</button> <button class="green" onClick="changeColor(this);">Btn3</button> <div id="Content"></div> And here is CSS code : .red { background-color: #ff0000; } .blue { background-color: #0000ff; } .green {

Javascript Sails.js server not starting anymore

I am using Cloud 9 IDE to develop a simple CRUD application using Sails.js (node.js MVC framework). Up until today I had no trouble starting the Sails.js server. Today, I've been trying to start the sails js server, but I keep getting this error: warn: error raised: Error: listen EACCES

Javascript Assign a random background.color to objects with random ID

JSFIDDLE I have created a button where a "person" is created every time you click on it. The person has a random ID (not a unique, I know). The next step for is to assign each of the people a random background color when they are created. What I've accomplished so far is that every time a new person is created, all of the people changes their color: $('#BtnCreatePerson').click(function(){ var sPersonName = $('#PersonName').val(); var sPersonLastName = $('#PersonLastName').val(); var sPers

Checking for empty form fields with a Javascript loop

I'm trying to loop through a small form and check for blank fields. I thought it would be simple, but I'm not able to get anything to work. This is my Javascript so far: var obj = { fname : document.getElementsByName('fname'), lname : document.getElementsByName('lname'), phone : document.getElementsByName('phone'), email : document.getElementsByName('email'), span : document.createElement('span'), txt : document.createTextNode('*Required Field'), init : function(){ document.getElements

Javascript Elements redefined while adding content

i have this code: <ul id="ul"></ul> <script> var playlist = document.getElementById('ul'); var li = document.createElement('li'); li.innerHTML = 'innerHTML'; playlist.appendChild(li); console.log(playlist.children[0] === li); // true playlist.innerHTML += 'some text'; console.log(playlist.children[0] === li); // false console.log(playlist.children[0]); // <li>innerHTML</li> console.log(li); // <li>innerHTML</li> &

Javascript How to call a codeigniter helper function using JQuery AJAX?

I have a function defined in my helper function in codeigniter that returns the formatted price when val and currency id is passed to it. if(!function_exists('format_price')){ function format_price($val,$curency_id=NULL){ $CI =& get_instance(); $CI->load->model('currency_model'); if ($curency_id) { $Result=$CI->currency_model->getcurrency($curency_id); $dec_place=round($Result['decimal_place']); $value=number_format((float)$val,$dec_place,'.',

Javascript Sort html table rows by first date column with jQuery

I have table with two date columns in each row start date and end date I want to sort table rows by start date with jQuery Below is the table html code: <table class="table-bordered"> <thead> <tr class="Headers"> <th>Number</th> <th>Date Start</a></th> <th>Date End</th> </tr> </thead> <tbody> <tr class="Entries" data-id="13"> <td data-field-type="string">1234</

Javascript Focus Only On Input and Buttons

Is it possible to only allow focus on certain elements, such as input and button? For example, if the user is focused on an input field, and they click off somewhere else on the page, that input retains focus. But if the user clicks another input or button, that new element gets focus. I have attempted to achieve this by event.stopPropagation(); and event.PreventDefault(), however, the elements still seem to lose focus. My current attempt looks like: $(document).on("click", function (even

Javascript Bootstrap datetimepicker strange positioning on a different div altogether

I am using bootstrap datetimepicker with formatting to enable only editing time in my code, I do it like this: function setTimepicker(object){ object.datetimepicker({ format: 'HH:mm' }); } I call this function in document.ready like so: $(document).ready(function(){ setTimepicker(starttimefield); setTimepicker(endtimefield); }); The html I am using is like this: <div class="panel-body"> <form id="myform"> <p> <b>

Javascript How to bind change event for checkbox in knockout js?

I'm using bootstrap switch to show checkbox as a switch and I want to bind a function to this switch, so the click data bind does not help here because the checkbox is not being clicked. So I probably need a "change" data bind like the onChange event that the checkbox have, but it didn't work when I tried to data bind change event to the checkbox... Here is my data bind: <input type="checkbox" onText="Active" offText="Inactive" data-bind="bootstrapSwitchOn: ActiveFlag, change: funct

Javascript Chrome Extension not playing sound when button is clicked?

I've created an extension for Google Chrome. There are no errors when uploaded, and the button appears just fine on the extension bar. The extension is supposed to play a sound when clicked, but it does not. Here is my manifest.json file: { "manifest_version": 2, "name": "Extension", "description": "My Extension", "version": "1.0", "browser_action": { "default_icon": "icon.png", "default_title": "Extension", "js": ["audio.js"] }, "permissions": [ "activeTab",

Javascript How to make user remake the function if the answer is not correct

I want to give user an question. Go to the left, right or continue straight. If user wrotes 'straight' in javascript prompt method. The other 2 methods are false - Game over. When is Game over I want user to make this story again. var prompt = propmt("Where will you go? Left, right or continue straight?"); if (prompt === "Left") { confirm("Game over, the tigers will eat you!"); } else if (where === "Straight") { confirm("You've won!"); } else { confirm("Game over, you've fallen to the riv

Javascript Finding animation code on website

I found on this website typewriter animation on main page but i can't seem to find the code running it. Is there anyway to track animations on websites and see what makes them tick? I use chrome developer tools to find java script file so i can read the source but i couldn't find it. **this function gives if element is being animated but i need how ** if (!$(element).is(':animated')) {...}

Javascript First Image In jQuery Slideshow Disappears After Cycling

this is a continuation of a post I made the other night, looking for help in coding a simple slideshow using jQuery and HTML. While the problem I had earlier has been fixed, I now have another issue: the first image in my gallery suddenly disappears after cycling through all of the images. When the page is initially loaded, the image is displayed correctly. The other images work properly as well, but once the slideImage variable resets back to 0, the first image no longer loads. I'm not sure wha

Javascript Delete row(TR) by clicking on a href

I have a table and i want to remove tr by clicking on a href tag. Here is the code. <tr> <td data-title="ID"> echo '<a href="" onclick="return Deleteqry('.$orderID.')";><font size="2" color="#FF0000"><i class=" fa fa-remove" title="Remove this Row"> </i></a>'; </td> </tr> <script> function Deleteqry(id) { if(confirm("Are you sure you want to delete this Row?")==true)

Javascript Rotate an element on scroll, what is the lightest way?

On a website i'm making at my internship, I want to make a arrow, that flattens once the user is scrolling down. I have tried to make this with jQuery, but this seemed to be very heavy for the browser. For this function, I used the .scroll() function, and a calculation that makes the arrow (triangle) flatter once the user scrolls down: $(window).scroll(function(e){ triangleRotation = 5.6125 - ($(window).scrollTop() / ($(window).height() / 7.3)); if (triangleRotation <= 0) {

Javascript Perform jQuery action when clicked again

I have the basis of my menu working, where when I click a menu element, it opens (similar to JQuery accordion), and when I click on another element in the menu, the previously opened menu closes and the newly clicked on opens. Here's what it looks like: Now, I'm trying to implement functionality to close the currently opened menu if it is clicked again. I'm using the slideUp(); method, but having a hard time figuring out where to put the additional code for the 2nd click on the same element

Javascript How refresh token works and how last failed http request called again which gave 401...?

I am working with a OAuth2 using angularjs. Now i got stuck in authentication with OAuth in which i am unable to resend last 401 api. Any Idea. I am using this oauth2 repo. Controller.js app.controller('validate', ['$scope', '$rootScope', '$location', 'fullname', '$http', '$timeout', '$cookies', 'OAuth', function ($scope, $rootScope, $location, fullname, $http, $timeout, $cookies, OAuth) { OAuth.getAccessToken($scope.user).then( function successCallBack(response){ $scope.response

Javascript Making An HTML element inside a D3-Tip Trigger Click Event

I am trying to trigger a click event from a button inside my D3-tip element as so: var tip = d3.tip() .attr('class', 'd3-tip') .html(function(d) { var html = "<div class='row text-center'><div class='col-md-4 no-gutters'>" + "<button class='btnn btnn-purple pull-left textSmall' id='1'>1</button>" + "</div><div class='col-md-4 no-gutters'>" + "<button class='btn

Javascript How do I create a dropdown that when selected updates an input field?

I have the below code to create a form input field which the user can type their search query into as normal. However, I also want to dropdown option to be part of this input. The problem I have, is that when the user selects an option from this dropdown, there is no placeholder text that appears in the input field or nor does the input text change to show the user what they just selected from the dropdown. I tried to write a small script which would detect if an li a was selected and it would u

Javascript AngularJS | Plnkr | Watch expression

I am new to angularjs. I am trying to run a sample code of $watch in plnkr, however, I cannot get watch expression triggered. Do I need to trigger digest cycle? <!DOCTYPE html> <html> <head> <script data-require="angular.js@1.2.0" data-semver="1.3.8" src="https://code.angularjs.org/1.3.8/angular.js"></script> <link rel="stylesheet" href="style.css" /> <script src="script.js"></script> </head> <body ng-app="funny"

Javascript Google Apps Script - Find Last Empty Row of a Column in Spreadsheet

I have currently a script like this: (Which will run every minute and fetch any values) // function 01 sheet2.getRange(sheet2.getLastRow() + 1, 1, 1, 6).setValues(values); // function 02 sheet2.getRange(sheet2.getLastRow() + 1, 10, 1, 6).setValues(values); It finds the last row and set the values in next row. Both are in separate functions. But currently it outputs something like this. Current Output : NOT GOOD // function 1 output here // function 2 output here ------------

Javascript Sending POST data to PHP script - jQuery, AJAX & PHP

I seem to be struggling with sending POST data to my PHP script. My AJAX sends data (an ID of a blog post) to my PHP script, which then finds the row that contains a matching ID from a database. The script then sends back the title of the blog post and the content of the post in an array, which AJAX picks up and inserts into a form in the DOM. I can successfully: insert sample data (for example, if I simply store strings into the array I'm passing back to AJAX, it will successfully insert t

Javascript Promise always pending (wrong syntax?)

I'm nearly new to node.js, express and ES6, but trying to get a hang of it. I wrote this code, trying to achieve neat clean ES6-driven functions and promises. But I've got a problem with inherited functions and values, especially next(). So here's my code written so far: let get_tags = (id) => { var id = id; return database.connection( (connection) => { return connection.query( `SELECT t.name

Javascript return last occurrence of name (many names) in an array of objects

Given the following data source: [ { "Username" : "Patrick", "Time" : "08:01:32", "Status" : "log in" }, { "Username" : "Patrick", "Time" : "08:34:31", "Status" : "idle" }, { "Username" : "Patrick", "Time" : "08:52:10", "Status" : "meeting" }, { "Username" : "Patrick", "Time" : "10:07:52", "Status" : "daily tasks" }, { "Username" : "Patrick", "Time" : "12:00:11", "Status" : "lunch" }, { "Username" : "Mark", "Time" : "07:40:32", "Sta

Javascript React Navigation : Bottom Up Transition

I'm using react-navigation in my react-native project in order to handle my navigation and routes. In my case, i have a ViewA and a ViewB. The ViewA needs informations that i'm filling in my ViewB. The userflow is ViewA -> ViewB -> ViewA. ** VIEW A ** import React from "react"; import { Button, Text, View } from "react-native"; class ViewA extends React.Component { state = { selected: false }; onSelect = data => { this.setState(data); }; onPress = () => { this.props.

How to return an HTTP response in Javascript?

I have a pop-up banner that looks something like this: if (confirm("Banner message")) { //do something if they accept } else { //do something else if they don't accept } If the user does not accept, I want to return a 403 Forbidden, preferably in a way that will get picked up by my httpd logs. What is the simplest way to do this?

How to display a canvas created with JavaScript?

I want to display a a image dynamically depending on a simple jQuery post request. However, the post request works well, but the canvas is not displayed anyway. I've tried like this: $.ajax({type: 'POST', url: 'http://....'}).done(function (data) { // data is beeing recieved correctly, it is not empty var imageBase64 = 'data:image/png;base64,' + data; var canvas = document.createElement("canvas"), ctx2d = canvas.getContext("2d"), size = 64, c

Javascript How to remove the extra space on the right margin of masonry layout

Using the Masonry layout library, I've created a two-column layout that you can see on codepen. There is an extra space seen on the right hand side of the layout. Could anybody tell me how to get rid of it? // external js: masonry.pkgd.js $('.grid').masonry({ itemSelector: '.grid-item', gutter: 4, columnWidth: '.grid-sizer', // percentPosition: true }); * { box-sizing: border-box; } body { font-family: sans-serif; } /* ---- grid ---- */ .grid { background: #EEE; max-width: 120

Javascript call Nodejs function from url

I want to execute a function inside a remote URL. I know the page URL where the function is and I know the Function name too. The server-side application is built on NodeJs Express. And the function itself look like this function executer(param1, parama2){ //logic return true; } Is there any way to achieve this?

Javascript DropDown Option Items as one item

i have an object with arrays and I would like to put every atribut from 1 array into 1 dropdownlist item. Currenty i have all attributs from arrays in 1 list item :( let optionItems = this.state.subsystems.map((subsystem, i) => <option key={subsystem["a:Name"]}>{subsystem["a:Name"]}</option> ); <div> <select> <option>{optionItems}</option> </select> </div> Thanks for help guys. Using NodeJs react

Javascript How to setState of this nested object?

Hi Im having troubles setting the state when I press a button 'Send' on one email input. I'm trying it avoiding mutation as React docs recommends. My state properties are this: state = { emailForm: { email: { elementType: 'email-invitation-input', elementConfig: { type: 'email', placeholder: 'Enter an email..', }, value: '', valid: true, required: true } }, requestStatus : false, validationMessage

Javascript Filter state in React without removing data

I'm trying to make a react component that can filter a list based on value chosen from a drop-down box. Since the setState removes all data from the array I can only filter once. How can I filter data and still keep the original state? I want to be able to do more then one search. Array list: state = { tree: [ { id: '1', fileType: 'Document', files: [ { name: 'test1', size: '64kb' }, { name: 'test2', size: '94kb'

Javascript Shopify API Access has been disabled

I try to create a Shopify application with koa. I use the koa-shopify-auth official package and the two methods shopifyAuth and verifyRequest to get a token with right scopes from the shop. After getting fresh and validated token with right scope, I make a request on https://xxx.myshopify.com/admin/api/2019-04/shop.json which is a simple endpoint to get information about the shop using app. Sometime I get the right answer from the API, but sometime I get an error: { "errors": "[API] API A

Javascript d3.js area graph with initial zoom

I am trying ti implement a zoom and brush chart with D3.js with an initial zoom. The initial zoom covers only about 10% of the brushable extent - this works correctly. When I zoom on the chart the first time, the zoom does not take into account the initial state. Here's the graph initially: And after the first zoom: Here's a plunkr, and the relevant code: svg.append("rect") .attr("class", "zoom") .attr("width", width) .attr("height", height) .attr("transform", "t

Javascript How to get scrollTop position realtime without jQuery?

I want to make make my navbar looks better with css effects. I have this as style classes: .bg-a1{ background-color: #23e896; color: white; } .bg-a2{ background-color: #1cb374; color: white; animation: all 0.3 ease-in-out; } .pad-nav-a{ padding: 30px; } .pad-nav-b{ padding: 20px; animation: all 0.3 ease-in-out; } now, i wanna add class pad-nav-b and bg-a2 when scrollTop > 10. I usually use jQuery: $(document).ready(function () { $(window).scroll(function () {

Javascript Handling synchronous flow in async generators JS

I am implementing a generator into my logic and it is not clear for me function *generator { yield synchronousFunc() yield asyncFunc() // should wait till asyncFunc() is completed // before calling next yield yield anotherSynchronousFunc() yield ... } how will it work if I convert this generator to async generator with async/await for for await (const item of generator()) {} when most of the yields are synchronous. How async generator will handle the synchronous

  1    2   3   4   5   6  ... 下一页 最后一页 共 8183 页