How can I change some text to lowercase and replace spaces with hyphens using jQuery?

前端 未结 5 1435
心在旅途
心在旅途 2020-12-24 12:06

I have a hidden input field that will take the value of another on keyup and I\'m trying to figure out how transform the value in the hidden field to lowercase and replace s

5条回答
  •  心在旅途
    2020-12-24 13:09

    To convert to lowercase :

    var lowercase = 'This Is A Sample'.toLowerCase();
    

    To Replace empty space:

    var Replace= 'This Is A Sample'.replace(/ /g,"-");
    

    take a look at this example

    @JSbin

提交回复
热议问题