Web Development

Remove Links and keep text in table or Div : Use it either for mobile or desktop

Suppose you have a table and you have information with links there. So in Desktop view you want to keep those information with links, but in mobile view you just want the information to show without wrapping links. Here is the JQuery code which i used to implement that. Basically i collected the code from stackoverflow and modified as per my requirements.

Here is the code

 <script>
$(document).ready(function() {
	  	 
	
	if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
		console.log(" mobile ");
  $('table tr td,table tr td').each(function(){
  
    if($(this).hasClass("nolink")){ 
    $(this).find("a").contents().unwrap();
    }
    });
}
});
 </script>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s