Vasileios Vasileios - 2 months ago 15
jQuery Question

Remove empty double quotes in jquery

enter image description here

How can i remove those empty double quotes that displayed inside the

<div class="nav-modal-main"></div>


Thank you in advance!

Answer

Use replace()

var tempStr = $('.nav-modal-main').text();
tempStr.replace(/"/g,  '').replace(/,/g,'').trim();

$(document).ready(function(){
  
var tempStr = $('.nav-modal-main').text();
$('.nav-modal-main').text(tempStr.replace(/"/g,  '').replace(/,/g,'').trim());
  
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="nav-modal-main">
",   "
  
  Testing
</div>

Comments