skip to Main Content

Unbind class selector jquery after changing class of a div

I am dynamically altering the class of a div when ajax request completes. <div id="MyDiv1" class="oldclass">Age</div> Inside the success function of ajax request : $('.oldclass').click({ alert('I am old'); }); $('.youngclass').click({ alert('I am young'); }); $.ajax({ ........ success: function(){ $('#MyDiv1').removeAttr('oldclass'); $('#MyDiv1').addAttr('youngclass');…

VIEW QUESTION

How to html text show as par this attribute in jQuery?

The problem is not shown in each tag. I face some issues like this: attr is not a function. $('document').ready(function() { jQuery('.custom-size .size .text').each(function() { var option_label = this.attr("option-label"); jQuery(this).text(option_label); }); }); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="custom-size"> <div class="size"> <div class="text"…

VIEW QUESTION

jQuery .attr() method returning undefined attribute value

The attr() method is returning "undefined" value of (v) when used with alert. Can someone help please? <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script> $(document).ready(function() { $("#decw").click(function() { $("#cht").attr("width",function(n, v) { alert(v); return v - 50; }); }); }); </script>…

VIEW QUESTION
Back To Top
Search