天道酬勤,学无止境

jquery

Drag and drop <span> to paragraph using JQuery

I need to drag and drop <span> to <p>. My code works, but I have 3 problems, When I edit <p> content by typing something(suppose three words) and after drag <span> to <p> newly typed words acting as one word. So cannot drop draggable components between those newly typed content. After the close, the added draggable components(by clicking X) two spaces are remaining between two words. Cannot drop the draggable component as the 1 word of the paragraph. To sort out the 3rd issue I added   to the 1st of the paragraph. and it's sorted. <p class="given" contenteditable="true">  Lorem Ipsum is simply

2021-09-24 19:58:07    分类:问答    javascript   jquery   jquery-ui   jquery-ui-draggable

How to delay a for loop in Jquery [duplicate]

This question already has answers here: How do I add a delay in a JavaScript loop? (34 answers) Closed 6 years ago. I am trying to make a image gallery and i am using a for loop to load all the images. but now I have the problem that it is going fast so I want to delay the the loop each time. I tried to set a timeout but that does not work does somebody know how to delay the loop with Jquery. js code: function test(){ var src = 'img/nature/'; var img = ['1.jpg']; var image = [ "1.jpg", "2.jpg", "3.jpg",'4.jpg','5.jpg','6.jpg','7.jpg' ]; for ( var i = 0; i < image.length; i = i + 1 ) { $('

2021-09-24 19:42:49    分类:问答    javascript   jquery

jQuery - Downloading Textarea Contents

How can I download the textarea value/contents when I click a button? It should act like PHP: <?php $file = 'proxies.txt'; if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.basename($file).'"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); readfile($file); exit; } ?> I just can't find any way on here to do it. I don't want it to make a href to click a second time to download. I

2021-09-24 19:31:00    分类:问答    javascript   jquery   html

Only add unique files to container?

I am using jQuery File Upload plugin - I have the auto upload file upload set to false and the behavior I have is that as files are added I build up a table showing the file name and a remove button to allow the user to remove the file before uploading. There is then an upload all files button? So if a user adds a file called foo.txt a row will be created. However if they add foo.txt again it will create another row. I want to check the existing table for that scenario and alert that to the user and not create the row. The code for the upload so far is: $('#uploadFile').fileupload({

2021-09-24 18:53:44    分类:问答    javascript   jquery   jquery-file-upload

jQuery Datepicker TH Year Issue

I already set below things for datepicker. I already added TH JS As well. https://github.com/jquery/jquery-ui/blob/master/ui/i18n/datepicker-th.js It's showing TH Month Name & Days. But not year $.datepicker.setDefaults( $.datepicker.regional[ "th" ] ); var currentTime = new Date(); var year = currentTime.getFullYear(); // Birth date $("#date-of-birth").datepicker({ changeMonth: true, changeYear: true, yearSuffix: year+543, yearRange: '-100:+0', dateFormat: 'dd/mm/yy' }); Because in TH. 29/03/2018 (EN) -> 29/03/2561 (TH) Thai Year is Current - 543 [Update] It's showing in Year Prefix, But not

2021-09-24 17:58:26    分类:问答    javascript   jquery   html   datepicker

PHP & JQuery uploader by Albanx - Blank Page

I'm trying to implement this PHP & JQuery uploader: http://code.google.com/p/ax-jquery-multiuploader/ I didn't change anything, and used the "Form integration and file rename" example as I need to send the gallery name in the form to set the folder path. The upload is working, but as soon as it's done, I get a blank page. I don't really understand why... And the weirdest thing: every time I try to modify the upload.php file given with the package to get a message, the upload seems not to work anymore (progress bar is stopping at circa 25% and nothing more happens, I stay on the same page), but

2021-09-24 17:31:06    分类:问答    php   jquery   upload

Symfony routing ajax get method

I pass by ajax GET parameters, my url looks like: example.com/autocamplete?term=string I add route for that: autocomplete: path: /autocomplete?term={term} defaults: { _controller: CatalogWebBundle:Default:autocomplete } But it something wrong with my route, because I get error: GET http://127.0.0.1:8000/autocomplete?term=sdfsd 500 (Internal Server Error) How to rewrite my route to ajax get patameters ? JS is: <script type="text/javascript"> $(function() { //autocomplete $("#search").autocomplete({ source: "\/autocomplete", minLength: 1 }); }); </script>

2021-09-24 16:33:41    分类:问答    php   jquery   ajax   symfony   routes

how to implement hover effect that fades in

when you hover over the left side (previous function) slides in and fades darker and vice versa for the right here's what I got so far thanks to Deleteman http://jsfiddle.net/pQzWp/

2021-09-24 16:24:55    分类:问答    javascript   jquery   css

Get dynamically created element that was click javascript

I'm trying to track what buttons users click via javascript/jquery. I have the following code $(document).on('click', '[data-tracker]', function( event ) { var target = event.target; var targetName = $(target).data('tracker'); console.log(targetName); }); <button data-tracker="test1">test1</button> <i data-tracker="test2">test2</i> <img data-tracker="test3"> At the moment this works as I want it to. When someone clicks on an element on the page that has the data-tracker attribute I log the value in the console. I'm using datatables on some pages which dynamically creates elements from json

2021-09-24 15:50:22    分类:问答    javascript   jquery

Where is this JQuery wrong?

I want to add the click event to all elements where the `id="violacao": $(document).ready(function () { jQuery('#violacao').click(function() { alert('teste'); }); }); But just the first link responds to the click. This is the HTML generated: <tr> <td><a href="#" id="violacao">40954589</a></td> <td>Perda de Comunicação</td> </tr> <tr> <td><a href="#" id="violacao">88692020503</a></td> <td>Perda de Comunicação</td> </tr> When I try this way: jQuery("a").click(function() { alert('teste'); }); It works fine, except that all links are affected. What is wrong?

2021-09-24 15:39:19    分类:问答    javascript   jquery   css-selectors