Category : jquery

I have this button. I just noticed, if I have the same class name on two nested elements, the click listener will fire twice. When I click, how can I fix this? $(‘body’).on(‘click’, ‘.remove’, function(e) { e.preventDefault(); if ($(e.target).hasClass(‘remove’)) { console.log(‘test’); //executed twice here } }) <script src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js”></script> <button type=”button” class=”btn remove “><i class=”fas fa-trash ..

Read more

I have this div.form-group dynamically added. I have index given to delete. my problem is that when I delete an elment in index 1 the third div also is deleted. how can I delete only one div by the given index <div class="mycontainer"> <div class="form-group"> <input type="text" class="form-control"> </div> <div class="form-group"> <input type="text" class="form-control"> </div> ..

Read more

I use this jquery code to show parts in tabs: <script> jQuery(document).ready(function ($) { $(".tab_content").hide(); $(".tab_content:first").show(); /* if in tab mode */ $("ul.tabs li").click(function() { $(".tab_content").hide(); var activeTab = $(this).attr("rel"); $("#" + activeTab).fadeIn(); $("ul.tabs li").removeClass("active"); $(this).addClass("active"); $(".tab_drawer_heading").removeClass("d_active"); $(".tab_drawer_heading[rel^=’" + activeTab + "’]").addClass("d_active"); $(".tab_content").hide(); var d_activeTab = $(this).attr("rel"); $("#" + d_activeTab).fadeIn(); }); /* if in drawer ..

Read more

my jquery functions not working after call calcBtnDisplacer(); this function swap two div with each other. here is my html : <section id="sec1Nd"> <label class="calc-label">Price<span class="input-required">*</span></label> <input type="text" name="amount" class="calc-input calc-amount"> </section> <section id="sec2Nd"> <label class="calc-label">Value<span class="input-required">*</span></label> <input type="text" name="amount" class="calc-input calc-amount-value"> </section> and here is my function : function calcBtnDisplacer(){ var sec1Nd,sec2Nd,amount,value,timer; amount = ..

Read more

INTRODUCTION I am using Bootstrap v4.6, jQuery latest and jquery-validation latest, in Symfony v5.2 project to validate user inputs. EXPECTATION I would like the validation to look the same – eather with JavaScript or PHP. STEPS TAKEN For that i took an example jquery-validation on GitHub I followed the example – yet part of error ..

Read more