Get value from a string after a special character

后端 未结 4 691
生来不讨喜
生来不讨喜 2021-01-30 10:26

How do i trim and get the value after a special character from a hidden field The hidden field value is like this

Code



        
4条回答
  •  再見小時候
    2021-01-30 10:49

    //var val = $("#FieldId").val()
    //Get Value of hidden field by val() jquery function I'm using example string.
    var val = "String to find after - DEMO"
    var foundString = val.substr(val.indexOf(' - ')+3,)
    console.log(foundString);
    Assuming you need to find DEMO string after - by above code you can able to access DEMO string substr will return the string from whaterver the value indexOf return till the end of string it will return everything.

提交回复
热议问题