Ch Hong Ch Hong - 5 months ago 31
Javascript Question

Javascript to remove spaces from .value

//loop thought all the sku field
$('.optionSku').each(function() {

//if found field are empty
if (jQuery.trim(this.value) == "") {

//loop thought all the name field to copy to the empty field
$('.optionName').each(function() {

if ($(this).closest("tr").find(".optionSku").val() == "") {



How to remove space from this.value?
I try to put
if (jQuery.trim(this.value) == "")
, but it cannot remove the space as well.

this.value =  this.value.trim(); 
//you need to assign the trimmed value back to it.