skip to Main Content

How to convert jQuery code to Pure JavaScript code?

I'd like to convert jQuery to Pure JavaScript but it doesn't work. jQuery: (document).ready(function() { $(".js-all-btn").on("click", this, function() { $(this).toggleClass("active"); $(".js-all-content").toggleClass("a-block"); } ); }); To Pure: document.addEventListener("DOMContentLoaded", function() { document.querySelector(".js-all-btn").on("click", this, function() { document.querySelector(this).toggleClass("active"); document.querySelector(".js-all-content").toggleClass("a-block"); }); }); Result: document.querySelector(...).on is…

VIEW QUESTION

Remove span tag from attribute title text using jquery

I want to remove <span> and <i> tag along with text in the title attribute. I have tried replace(/<span>(.*?)</span>/g, '') but it's not working. Anyone help to achieve this. containerval = $('p').attr('title') k = containerval.replace(/<span>(.*?)</span>/g, '') console.log(k,'kkkk') <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <p…

VIEW QUESTION
Back To Top
Search