remove url from anchor tag href

Remove window url from anchor tag href that contain # hash. Means we need to remove url from hash to start.

var links = document.querySelectorAll('a');

		links.forEach((item) => {
			//check each item has 'inner'
			if(item.href.includes('inner')){
				if(item.href.indexOf('#') != -1){
					item.href = item.href.slice(item.href.indexOf('#'));
				}
			}
		})

Also now you need to change click jQuery code.

$('body').on('click', '.menu_area .wrapper .inner_wrapper ul li a[href^="#"]', function(){
console.log('hello')
});

Leave a Reply

Your email address will not be published. Required fields are marked *