skip to Main Content

Jquery – If hasClass then addClass to parent node

I am trying to add new class to the parent class if nodes has a certain class. $(document).ready(function() { if ($(".row").hasClass("lock-icon")) { $(".row .lock-icon").parent(".content-box").addClass('locked-badge'); } }); .locked-badge { opacity: 0.2; cursor: not-allowed; } <div class="col-md-6 mb-5"> <div class="content-box"> <div class="row">…

VIEW QUESTION

Jquery – adding json data value

I am trying to create cart using js function fuBuyNow() { var prodqty = 1; var prodid = localStorage.ls_productID; var prodprice = $('#ppriceoffer').html(); var cartItem = { productid: prodid, productqty: prodqty, productprice: prodprice }; var cartItemJSON = JSON.stringify(cartItem); console.log(cartItemJSON); var…

VIEW QUESTION

how do i change the color of a div in jquery with radio button clicked and change the background color with the second radio button clicked?

<body> <input type="radio" id="txtElement3" />Voorgrond<br /> <input type="radio" id="txtElement2" />Achtergrond<br /> <input type="text" id="txtElement"> <button id="btnKnop1">Stel kleur in</button> <div id="divResult">Voorbeeld tekst</div> <script> $(document).ready(function () { $("#btnKnop1").on('click', function () { if ($('#txtElement3').is(':checked')) { var txtElement = $('#txtElement').val() $('#divResult').css('color', txtElement) } if…

VIEW QUESTION
Back To Top
Search