skip to Main Content

Jquery – Html select based on another select

Can someone help me correct this code. I need value attribute for some other purpose. I need the form to post both the category id and subcategory id. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> <script> $(document).ready(function(){ var $optgroups = $('#subcategory > optgroup'); $("#category").on("change",function(){ var…

VIEW QUESTION

Jquery – How to replace element's attr href with each

I want to change the href URL from the HTML string. But it prints the old URL instead of the test.php var html='<div><a href="https://www.spectrum.net/support/manage-account/creating-username?cid=eml_ehh_60_0621">find out how</a></div>'; $(html).find('a').each(function(){ var newUrl = "test.php"; $(this).attr("href", newUrl); }); console.log(html); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> OUTPUT: <div><a href="https://www.spectrum.net/support/manage-account/creating-username?cid=eml_ehh_60_0621">find…

VIEW QUESTION
Back To Top
Search