Swap an element with another element
Hello friends, i am new to jquery and i am trying to swap or move an element with another element, but it's not working completely. I have following html: <div id=content> <div class=c1> <a href="link1"><img src="" alt=""></a> <h2>Headline 1</h2> <p>...</p> <p>...</p> </div> <div class=c2> <a href="link2"><img src="" alt=""></a> <h2>Headline 2</h2> <p>...</p> <p>...</p> </div> <div class=c3> <a href="link3"><img src="" alt=""></a> <h2>Headline 3</h2> <p>...</p> <p>...</p> </div> </div> And I want
How to preview values of dynamically generated fields in rows of a table-include a row for data returned from database
I'm trying to build a form on my website where users can make orders. More fields can be generated dynamically for more orders and a table is displayed previewing the orders so far. However, i intend to incorporate a functionality where costs (and then maybe the total cost too) of each product ordered is displayed on a td on each row of the preview table along with the product and the quantities ordered. I have a php page which echoes the cost of each product as selected from database, and then fetch
Why I am getting 'Access-Control-Allow-Origin' when I run locally???
I am making the following request $.ajax({ url: "http://localhost:8181/data/status", type: "GET", success: function(response) { console.log(response); }, error: function(xhr, error){ console.debug(xhr); console.debug(error); } }) and unexpectedly getting the following response. XMLHttpRequest cannot load http://localhost:8181/data/status. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080'
Add pagination to a Table in a sucess function
I am using ajax options with a target Id on a table. Now I need to add Pagination to the table See the code below. I need to add pagination so when the target.append renders, it renders with pagination. select: function (event, ui) { $.ajax({ cache: false, async: false, type: "GET", url: "@(Url.Action("Test", "TesPage"))", dataType: 'json', data: { "id": ui.item.Id }, success:
How to preview values of dynamically generated fields in rows of a table
I desperately need some guidance in solving this, please. I have a form on my website where users fill an input field and selects from a drop down. For more options, a button is provided to generate more fields dynamically for users. That works fine. Now, I’m trying to implement a functionality that previews the orders made by users (in a table format) immediately the user finish filling the orders field and the name field receives focus. With what i've done so far I'm having all the values displayed
Slideup div to display
Hi, I can't seem to work this out despite crawling the web and trying different things, I'm trying to create 4 boxes that would slide up (previously hidden) to display content in this div followed in succession when the page loads. I want them to stay open so I don't need a close feature. Would appreciate someone's help. Cheers
Dynamic variable names and values
Hi, I have my variables in my database fields var_name and var_value is it possible when doing $.each to create the variables and assign its values, something like this: -------- -------- -------- my.[[[var_name]]] = [[[var_value]]] -------- -------- -------- Thanks, Jassim
want to unwrap html using jquery/javascript
I want to unwrap below html using jquery or javscript. for wrap i used below code but on few pages I want to unwrap that part. $('.ms-rte-embedcode.ms-rte-embedwp') .wrap('<div class="container"><div class="row"><div class="col-xs-12"/></div></div>'); Now I want to unwrap parent div's of class "ms-rte-embedcode ms-rte-embedwp". Html: <div class="container"> <div class="row"> <div class="col-xs-12"/> <div class="ms-rte-embedcode ms-rte-embedwp"> Test</> </div> </div> Thanks.
Insecure Randomness and Code Injection on 1.10.2 version
Our team is using the jquery library version 1.10.2 for our jquery needs for the internal site. During our recent Fortify security scan, we found various vulnerability like the Insecure Randomness and Code Injection. I am attaching the screen shots of this vulnerability. Can you please give your feedback
How to compare multiple radio button's value with string?
I'm wondering how to get the multiple selected radio button's value and compare with string? If people click more than one radio buttons, then show all the text that compare with the radio's value. I can now show the text that compare with only one radio button's value, but if I click more than one radio buttons, it still shows the text that I select at first time. For example, in this case: JSFiddle If I click "apple", it shows "apple apple" that's correct, but if I click more than one buttons
done or success for $.each
Hi, Why I am getting: Error: 'Uncaught TypeError: $.each(...).promise is not a function', line 132, file 'http://localhost:53470/views/signin.js'. $.each(data, function (index, item) { -------- run some code here ------------- ------------ }).promise().done(function () { alert("All was done"); }); Isn't there any done or success for the $.each? kindly advise how to achieve done or success for $.each Thanks, Jassim
how to find all elements with an attr in jquery?
I found this example but it specifically searches all inputs as opposed to all elements: https://api.jquery.com/attribute-equals-selector/ How can I update this example to search *all* elements in the DOM, not just inputs for those that contain a particular attribute like "myAttribute"?
How to select input type "tel" using jquery by id..??
In my form, I have an input field of type="tel". <input type="tel" name="jform[work_phone]" class="validate-phone" id="jform_work_phone " value="" size="30"> I am setting value to this field using jQuery by jQuery("#jform_work_phone").val("123456"); It is not setting the value. What am I doing wrong..??
toggle closest div tag not working
If you could please help me out with this. I have multiple div tags to show and hide based on he user clicking the plus image. The image isn't uploaded so just click on the placeholder in the example below. What is supposed to happen is based on the + image the user clicks on that div tag should expand to show the extra text. I can only get the top div tag to show/hide at this time. https://jsfiddle.net/hosm8u5s/#&togetherjs=G6TkU6eIcB
Clone svg elements
I'm trying to clone circle components w/in an svg element after first pass but it's putting it in the dom: <svg width="100%" height="100%" viewBox="0 0 42 42" class="donut"> ... <circle class="donut-segment" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#ce4b99" stroke-width="6" stroke-dasharray="0 0" stroke-dashoffset="25"> <desc id="donut-segdesc-0">Some description</desc> </circle> ... </svg> Clone & add another circle & it's desc after the last circle: var firSeg
on('mouseover') not getting associated with element as expected
I'm using the following code to associate a mouseover event with an <a> tag: $('#' + control.Id).on('mouseover', function(){ alert('test'); }); control.Id is a valid control ID that exists on the page. The following code gets a handle to the control on the page: $('#' + control.Id) However, when I try to associate a mouseover event with the on('mouseover') code above, the CDT watch shows "onmouseover: null". Any idea why my on('mouseover') code does not appear to be working as expected?
How to do synchronous Promise.then() chaining in jQuery v3?
Hi, we have a lot of code where we rely on the jQuery v2 behavior of synchronous calls for promise.then chaining: function getResolvedPromise() { return $.Deferred().resolve("A"); } console.log("code BEFORE processing stuff"); var prom = getResolvedPromise(); prom = prom.then(function (value) { console.log("then1: " + value); return "B"; }); prom = prom.then(function (value) { console.log("then2: " + value); return "C"; }); prom.done(function (value) { console.log("done: " + value); });
Jquery Ajax with Authorization Headers
I am trying to make Jquery Ajax call to a REST Service.The service excepts Basic authentication which requires User Name & Password. So, while making the Ajax request i have added the Authorization tag in the code.But still i don't see the Authorization tag after the request. var username = "user";
var password = "pwd";
var url = 'mysite.com';
$.ajax({
url: url,
success: function(json) {
alert("Success", json);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
Variable in Select not update
Hi, im whit this code var num=1; var num2; $(document).ready(function(){ $('.cntrlr-'+num+'-ok').on('click', function() { num2=num+1; $('.scnr-'+num).addClass('hidden'); $('.scnr-'+num2).removeClass('hidden'); num=num+1; }); The problem is into $('.cntrlr-'+num+'-ok'), only go when the class of object clicled is 1 (.cntrlr-'1'-ok'). The num variable change correctly but the $('.cntrlr-'+num+'-ok') not update. Thanks,
how to check some key and if all values of this key are empty
Hi, I've got this code but it's not correct var test_h2s = JSON.parse($.cookie('name_of_cookie')); JSON.stringify(test_h2s, function(key, value) { // when encoutering one of the keys we're looking for, with all values empty while(key.substr(0, 3) === 'h2s' && value !== "") { //do something }
How to force Google Chrome open "save as" dialogue?
Are there any way to force Google Chrome open "save as" dialogue if user didn't change browser's default setting? I know the dialogue can pop-up if user switch on "ask where to save each file before downloading" in Chrome's advanced settings, but I can't ensure every user knows that. Anybody know the solution? Thanks for any answer.
Allow minus character at first in input box
Hi , I am using the below code to allow minus (-) sign at the first position, where it is happening. But if in case i enter a number and then move the cursor to first position i am unable to enter the minus (-) sign. http://jsfiddle.net/7XLqQ/3/ Looking forward for the response. Thanks in Advance, Ravindra
trigger a swipe event
hi I'm using this great swipe function that works perfectly. found here: http://labs.rampinteractive.co.uk/touchSwipe/demos/Basic_swipe.html I can't find a way to trigger this swipe event from another div click. That is to say - user clicks on #div1 and it fires $(#test).swipe.I tried trigger, bind event, a few other things and no luck. any clues ?
GET method returns 500 Internal server error.
Hello. I'm new here so I have some question. So I'm developing a web page, but there ir some problem. I have map with are tags, that onclick runs a function "getObject(this.alt)". function getObjects(object){ console.log(object); $.get("/sites/map/objects.php?t="+object, function(data) { $('#answer').html(data); }); Ir runs file object.php were t= area tags alt attribute, the objects.php connects to MySql and returns objects row, but I get this kind of error: GET http://mysite.com/sites/map/objects.php?t=some_object
How to get all elements with this multi value attribute?
Assume I have a web page with multiple instances of elements that have (among others) the following CSS definition: #........... { ..... border: 1px dashed #ddd; ..... } How can address all these elements with jQuery? The following does not work: $("[border: 1px dashed #ddd]") How else does that work? Peter
Two buttons for one form
Hi, I have below view which has Save and Delete buttons.. The Save button will invoke: $('#frmContact').submit(); But What's the best way to invoke the Delete button? Kindly advise.. <div id="popupCustomerContact" style="display: none;"> <form id="frmContact"> <div id="lookupContactCategory" style="margin-bottom: 20px;"></div> <div id="txtContactDetails" style="margin-bottom: 20px;"></div> </form> <center> <div id="btnDeleteContact" class="savannadeletebutton"
data-* attribute
I am using the data-* attribute to give specific elements unique data and am using the element.dataset.value syntax to read the values when i try to read the values the data names are always lower case even if i used upper case in the html so <div id="a" data-User> object = document.getElementById("a"); //DOES NOT WORK object.dataset.User //DOES WORK object.dataset.user why is this?
show certain div by choosing option in two select's (html form tag)
Create a simple html page with a form. Form elements: - dropdown 1 options: red, green, blue - dropdown 2 options: rectangle, circle - button “Add” 1. When user clicks “add”, the appropriate figure should appear on the page. 2. User should be able to remove any figure 3. Add clear button, which clears all figures on the page should use jQuery. how to do it ? I'd try something like this: HTML <div id="main"> <form action="#"> <ul> <li> <select id="color" name="color">
How to show an alert (or hidden div) when selecting a particular option in a select element
This is probably a simple question, but I'm not sure how to do it. I'd like to have an alert of some type, either standard alert or a hidden div, show up when a user selects an option in a select element. For instance, if a select element has 5 options in it and the user chooses the first one, they would get an alert that says "You have chosen the first option". I'm confident this is something that can be done with a few lines of code, but I'm not sure where to begin. Here's the logic - I'm just
Conditional hiding and showing divs
I have two divs (div1 and div2) which I would like to be shown depending on whether a checkbox is checked and which option is selected from a dropdown box. I currently have this code but it doesn't work very well since if the checkbox is unchecked, the divs are still shown and i don't know how I would fix this: Any help would be fantastic! <script> $(function() { $('#div1').hide(); $('#div2').hide(); $('#boxid').change(function()
How to make price and add to cart sticky ( fixed to top ) when scrolling down on mobile ?
So Im using this The single _variation_wrap is the class that has both the price and add to cart $(document).scroll(function () { if ($(this).scrollTop() > 40) { $("single_variation_wrap").addClass("sticky"); }else{ $("single_variation_wrap").addClass("sticky"); } }); and then .sticky{ position:fixed; top:10px; right:10px; } But nothing is happening .. Please Anyone?
Why is the panel not showing?
Hi guys Im using jQuery and I have the following problem. I have a button that shows and displays an adjacent panel, and everything works well, except in that panel i have a button to load some data, and when I click that button, the other button to show the panel doesnt show it again after hiding it. My jquery is following: var add_student_toggle = false; $("#add-student-link").click(function() { if (add_student_toggle == true) { $("#col-students").removeClass("col-lg-8");
Tagit autocomplete not working on mouse click.
Hi All, Is there anyone who have worked with tagit functionality? I have few issues. 1- while using autocomplete , unable to create tag on mouse click. 2- how to add IDs that I am bringing from database. 3- how to get those ids at the time of remove tag?4- Basically want to add and delete tags value on database using PHP. 5- The most unusual issue here is why I am using select: , after mouse click on suggested list, it don't convert that into tag, I have to do an extra enter (key) press to make that
Radio button toggle issue
Does anybody know how to fix the toggle failure problem if the radio button set TRUE at the very first beginning? I have to click twice to toggle the radio if the button is already checked, but my code can work perfectly if radio button unchecked at the beginning. Thanks for any help. JSFiddle is here: JSFiddle Or you can check the code here... HTML part: <input type="radio" id="toggleMe" checked> <label for="toggleMe">Toggle Me!</label> JQuery part: $("#toggleMe").click(function(){ var radio =
Can't get .on(change... to work regardless of where I put code
Here we go again!! I've given up trying to run all code on one page(php). Now have tree2.html (client side), and tree2.php (server side) Below is the tree2.html of my program. I can't get the .on(change .. part to work as an empty tiny, tiny table is displayed before I can enter data into the <input> block. I know this has to do with the asyn running of HTML but how do you make this work? <!DOCTYPE html> <html> <head><title>tree2.html Sun 02Jul2017</title> <meta http-equiv="content-type"
Why ajax is sending multiple POSTs?
Hi In the video.. why ajax sends multiple POSTs? sometimes, 2, 3, 4 or 5 times.. https://www.jassimrahma.net/temp/2017-07-05_0325.swf I have nothing in my PHP does that.. Here is the code: $("#frmContact").on("submit", function (event) { event.preventDefault(); var formData = new FormData(); formData.append("savanna_account", Savanna.savanna_account); formData.append("customer", customer_id); if (e.component.option("tag")) { formData.append("contact_id", contact_id);
My Script is making jQuery not responding
Hi, I have an script with windowssize conditions for responsive functionality in jQuery. But if I scale the window I get the error that a jQuery is not responding. I have tried to comment something out in my code to test if the script will work better but I don't have getting a positive reaction. Here is my code: https://gist.github.com/janstieler/fb88fe9dbc720e06cfeb57dd0fe4fdf3 (It was too long for paste it directly here) I would appreciate if soemone can help me! Kind regards
Iryna Kyryk - How to resolve Jquery Error in website?
Hello, I am Iryna Kyryk and I am currently working on a website and getting jquery errors. Since I am new to jquery can anyone help how to remove these errors? Thanks
How to send null in formData
Hi, I have the following line: if (Savanna.loggedon === true) formData.append("savanna_account", Savanna.savanna_account); else formData.append("savanna_account", null); I need when the Savanna.loggedon is not true to make the savanna_account null so I can save it as null in MySQL But currently when the loggedon is not true then the savanna_account is passed as 0 (ZERO) How can I fix this please? Thanks, Jassim
How to update all users page automatically after delete of posts on forum page without page reload
Kindly assist please. I'm working on a forum page with php and jquery/ajax. When i delete a post, my page is immediately updated. However, other logged-in users still see the deleted post until their pages are reloaded. What i want is a functionality that updates all logged in users pages without page reload. My fetch_posts.php file outputs the result of the sql select statement as a JSON encoded data to my jquery file. Here is some of the relevant contents of my jquery file. function fetchPosts(){
Next Page