jquery

Prevent submit form twice with change event

走远了吗. 提交于 2021-01-28 07:05:57
问题 i hava a form with a hidden submit button and one text input. In the text input, with jQuery i attached to it a change event that submits the form. The thing is that if i hit enter on the input, then the form submits twice. I think is because the enter submits the form and the input detects a change event and it submit the form again. I have two questions: - Is my thought right? - How can i fix this? This is the javascript: $("input.price").live('change', function () { $(this).closest('form')

addressing and setting 2 datepicker fields on WordPress with Ninja Forms

只愿长相守 提交于 2021-01-28 07:04:38
问题 On WordPress is use Ninja Forms. i have a page with multiple Date Fields in the same Form ( date of arrival and date of departure). I need to change the Value of both Date fields. the following example script works (i can add jQuery to the page by a WP plugin), but is changing the value of both fields: <script> $( document ).ready( function() { new(Marionette.Object.extend( { initialize: function() { this.listenTo( Backbone.Radio.channel( 'pikaday' ), 'init', this.modifyDatepicker ); },

Javascript - Change input letter before written down textarea

∥☆過路亽.° 提交于 2021-01-28 07:03:47
问题 I'm trying to make a virtual keyboard with jQuery. When I press 'a' in the given textarea, suppose that 'z' should be written instead. In textarea, I found the whole steps of typing a letter is given by keyDown event → keyPress event → letter typed in textarea → keyUp event In my code, I detected the letter in keyPress event and in that event, if the letter was 'a' , I added 'z' in textarea using .val() method. If we have the initial string hello in textarea, after keyPress event , we have

jQuery click() only once

丶灬走出姿态 提交于 2021-01-28 06:51:26
问题 I want to make it so that this button can be clicked only once. If someone clicks it more times then the function will not be performed. How can I do that? $(".btn_ranking").click(function(e) { e.preventDefault(); var name = localStorage.getItem('name'); var time = localStorage.getItem('timer_end'); $.ajax({ url: "php/file.php", method: "POST", data: { name: name, time: time } }) }); 回答1: Use one() to attach the event handler: $(".btn_ranking").one('click', function(e) { e.preventDefault();

count characters textarea and change color counted

。_饼干妹妹 提交于 2021-01-28 06:44:28
问题 I have the simple code, it's works fine. This code counting characters in textarea and result show in div 0,1,2 etc. I would like obtain effect when result counted is < 100 font-color will be red and when counted result is > 100 change font-color on green. How can i do it? function countChar1(val) { var len = val.value.length; $('#charNum').text(0 + len); }; <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script> <textarea id="opis_siebie" type="text" rows="6"

Dynamic form not submitting (jQuery)

夙愿已清 提交于 2021-01-28 06:43:19
问题 I'm creating a simple task manager app with PHP, MySQL, & jQuery. I'm adding a feature that will allow users to add a task by clicking a "new task" button, typing into a text field and hitting enter. This is the jQuery I have: function add_task() { // Add the "add new task" button $("<span class='add-new'>Add new item</span>").appendTo(".sub-phase"); // String for the input form var task_form = '<form class="add-new-task" autocomplete="off"><input type="text" name="new-task" placeholder="Add

changing language of jquery-ui datepicker

余生颓废 提交于 2021-01-28 06:41:15
问题 hello im new to jquery and since my application is in french I want to change the language of datepicker to match it since not everyone who will use the app knows english Here is my datepicker with jquery-ui as a simplified version: <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script> $(document).ready(function (

What does jquery.js, foundation.js, and foundation.alert.js do?

≯℡__Kan透↙ 提交于 2021-01-28 06:39:20
问题 I asked a previous question earlier about flash messages and how to customize them, but I could really use some clarification about what these files are? <script src="js/vendor/jquery.js"></script> <script src="js/foundation/foundation.js"></script> <script src="js/foundation/foundation.alert.js"></script> What are they and why do I need them? Foundation makes it sound as if it was already included.Am I supposed to put code in them, my rails app doesn't have a vendor directory or jquery.js

Is there a way I can check how long it takes for javascript to execute a function in milliseconds?

只愿长相守 提交于 2021-01-28 06:34:44
问题 I have code like the following: oTable = $('#dataTable').dataTable({ "sScrollX": "100%", "bScrollCollapse": true, iDisplayLength: -1, aLengthMenu: [[-1, 25, 50, 200, "All"], [10, 25, 50, 200, "All"]], aoColumnDefs: [ { "sSortDataType":"dom-data-rk", "aTargets": ["sort-data-rk"] }, { "sType": "date-uk", "aTargets": ["sort-date-uk"] }, { "sType": "datetime-uk", "aTargets": ["sort-datetime-uk"] } ] }); Is there a way I can time how long this code takes to execute using javascript or jQuery.

Bootstrap Tab shows but does not highlight until clicked

寵の児 提交于 2021-01-28 06:30:27
问题 I am using Twitter Bootstrap (v3.0.3) Tabs, and they are working perfectly except... the tab that I have marked as active does not visually highlight unless you click on it. The interesting thing is I can reproduce this behavior using jsFiddle and the example code from the Twitter Bootstrap website: Bootstrap Example: http://getbootstrap.com/javascript/#tabs jsFiddle: http://jsfiddle.net/uXV56/ Example Tab Code: <!-- Nav tabs --> <ul class="nav nav-tabs"> <li><a href="#home" data-toggle="tab"